CVS: beepcore-java/src/org/beepcore/beep/core MessageImpl.java,NONE,1.1 MessageMSGImpl.java,NONE,1.1 Message.java,1.11,1.12 ChannelImpl.java,1.5,1.6 MessageMSG.java,1.9,1.10 SessionImpl.java,1.6,1.7

Huston Franklin <[email protected]> Tue, 03 Jun 2003 09:38:39 -0700
Newsgroups gmane.network.beep.beepcore.java.cvs
Message-ID <[email protected]>
Update of /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/core
In directory sc8-pr-cvs1:/tmp/cvs-serv24317/src/org/beepcore/beep/core

Modified Files:
	Message.java ChannelImpl.java MessageMSG.java SessionImpl.java 
Added Files:
	MessageImpl.java MessageMSGImpl.java 
Log Message:
more interface refactoring

--- NEW FILE: MessageImpl.java ---
/*
 * Message.java            $Revision: 1.1 $ $Date: 2003/06/03 16:38:35 $
 *
 * Copyright (c) 2001 Invisible Worlds, Inc.  All rights reserved.
 * Copyright (c) 2003 Huston Franklin.  All rights reserved.
 *
 * The contents of this file are subject to the Blocks Public License (the
 * "License"); You may not use this file except in compliance with the License.
 *
 * You may obtain a copy of the License at http://www.beepcore.org/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied.  See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 */
package org.beepcore.beep.core;


/**
 * Message encapsulates the BEEP MSG, RPY, ERR and NUL message types.
 *
 * @author Eric Dixon
 * @author Huston Franklin
 * @author Jay Kint
 * @author Scott Pead
 * @version $Revision: 1.1 $, $Date: 2003/06/03 16:38:35 $
 */
public class MessageImpl implements Message {

    /**
     * Uninitialized BEEP message.
     */
    public static final int MESSAGE_TYPE_UNK = 0;

    /**
     * BEEP message type.
     */
    public static final int MESSAGE_TYPE_MSG = 1;

    /**
     * BEEP message type.
     */
    public static final int MESSAGE_TYPE_RPY = 2;

    /**
     * BEEP message type.
     */
    public static final int MESSAGE_TYPE_ERR = 3;

    /**
     * BEEP message type.
     */
    public static final int MESSAGE_TYPE_ANS = 4;

    /**
     * BEEP message type.
     */
    public static final int MESSAGE_TYPE_NUL = 5;

    /** BEEP message type of  <code>Message</code>. */
    int messageType = MESSAGE_TYPE_UNK;

    /** <code>Channel</code> to which <code>Message</code> belongs. */
    ChannelImpl channel;

    /** Message number of <code>Message</code>. */
    int msgno;

    /** Answer number of this BEEP message. */
    int ansno;

    /**
     * BEEP message type for utility only.
     */
    private static final int MESSAGE_TYPE_MAX = 6;

    private static final String NOT_MESSAGE_TYPE_MSG =
        "Message is not of type MSG";

    private boolean notified = false;

    /**
     * Payload of the <code>Message</code> stored as a
     * <code>InputDataStream</code>
     *
     * @see org.beepcore.beep.core.InputDataStream
     */
    private InputDataStream data;

    /**
     * Creates a new <code>Message</code>.
     *
     * @param channel <code>Channel</code> to which this <code>Message</code>
     *    belongs.
     * @param msgno Message number of the BEEP message.
     * @param data  <code>InputDataStream</code> containing the payload of the
     *    message.
     * @param messageType Message type of the BEEP message.
     *
     * @see InputDataStream
     * @see Channel
     */
    MessageImpl(ChannelImpl channel, int msgno, InputDataStream data,
                int messageType)
    {
        this.channel = channel;
        this.msgno = msgno;
        this.ansno = -1;
        this.data = data;
        this.messageType = messageType;
    }

    /**
     * Creates a BEEP message of type ANS
     *
     * @param channel <code>Channel</code> to which the message belongs.
     * @param msgno Message number of the message.
     * @param ansno
     * @param data  <code>InputDataStream</code> contains the payload of the
     *    message.
     *
     * @see Channel
     * @see InputDataStream
     */
    MessageImpl(ChannelImpl channel, int msgno, int ansno, InputDataStream data)
    {
        this(channel, msgno, data, MESSAGE_TYPE_ANS);

        this.ansno = ansno;
    }

    /**
     * Returns <code>InputDataStream</code> belonging to <code>Message</code>.
     *
     * @see InputDataStream
     */
    public InputDataStream getDataStream()
    {
        return this.data;
    }

    /**
     * Returns the <code>Channel</code> to which this <code>Message</code>
     * belongs.
     *
     * @see Channel
     */
    public Channel getChannel()
    {
        return this.channel;
    }

    /**
     * Returns the message number of this <code>Message</code>.
     */
    public int getMsgno()
    {
        return this.msgno;
    }

    /**
     * Returns the answer number of this <code>Message</code>.
     */
    public int getAnsno()
    {
        return this.ansno;
    }

    /**
     * Returns the message type of this <code>Message</code>.
     */
    public int getMessageType()
    {
        return this.messageType;
    }

    /**
     * Sends a message of type ANS.
     *
     * @param stream Data to send in the form of <code>OutputDataStream</code>.
     *
     * @see OutputDataStream
     * @see MessageStatus
     * @see #sendNUL
     *
     * @return MessageStatus
     *
     * @throws BEEPException if an error is encoutered or if messageType is
     *         not MESSAGE_TYPE_MSG.
     */
    public MessageStatus sendANS(OutputDataStream stream) throws BEEPException
    {
        throw new BEEPException(NOT_MESSAGE_TYPE_MSG);
    }

    /**
     * Sends a message of type ERR.
     *
     * @param error Error to send in the form of <code>BEEPError</code>.
     *
     * @see BEEPError
     * @see MessageStatus
     *
     * @return MessageStatus
     *
     * @throws BEEPException if an error is encoutered or if messageType is
     *         not MESSAGE_TYPE_MSG.
     */
    public MessageStatus sendERR(BEEPError error) throws BEEPException
    {
        throw new BEEPException(NOT_MESSAGE_TYPE_MSG);
    }

    /**
     * Sends a message of type ERR.
     *
     * @param code <code>code</code> attibute in <code>error</code> element.
     * @param diagnostic Message for <code>error</code> element.
     *
     * @see MessageStatus
     *
     * @return MessageStatus
     *
     * @throws BEEPException if an error is encoutered or if messageType is
     *         not MESSAGE_TYPE_MSG.
     */
    public MessageStatus sendERR(int code, String diagnostic)
        throws BEEPException
    {
        throw new BEEPException(NOT_MESSAGE_TYPE_MSG);
    }

    /**
     * Sends a message of type ERR.
     *
     * @param code <code>code</code> attibute in <code>error</code> element.
     * @param diagnostic Message for <code>error</code> element.
     * @param xmlLang <code>xml:lang</code> attibute in <code>error</code>
     *                element.
     *
     * @see MessageStatus
     *
     * @return MessageStatus
     *
     * @throws BEEPException if an error is encoutered or if messageType is
     *         not MESSAGE_TYPE_MSG.
     */
    public MessageStatus sendERR(int code, String diagnostic, String xmlLang)
        throws BEEPException
    {
        throw new BEEPException(NOT_MESSAGE_TYPE_MSG);
    }

    /**
     * Sends a message of type NUL.
     *
     * @see MessageStatus
     * @see #sendANS
     *
     * @return MessageStatus
     *
     * @throws BEEPException if an error is encoutered or if messageType is
     *         not MESSAGE_TYPE_MSG.
     */
    public MessageStatus sendNUL() throws BEEPException
    {
        throw new BEEPException(NOT_MESSAGE_TYPE_MSG);
    }

    /**
     * Sends a message of type RPY.
     *
     * @param stream Data to send in the form of <code>OutputDataStream</code>.
     *
     * @see OutputDataStream
     * @see MessageStatus
     *
     * @return MessageStatus
     *
     * @throws BEEPException if an error is encoutered or if messageType is
     *         not MESSAGE_TYPE_MSG.
     */
    public MessageStatus sendRPY(OutputDataStream stream) throws BEEPException
    {
        throw new BEEPException(NOT_MESSAGE_TYPE_MSG);
    }

    boolean isNotified()
    {
        return this.notified;
    }

    void setNotified()
    {
        this.notified = true;
    }
}

--- NEW FILE: MessageMSGImpl.java ---
/*
 * MessageMSG.java  $Revision: 1.1 $ $Date: 2003/06/03 16:38:35 $
 *
 * Copyright (c) 2001 Invisible Worlds, Inc.  All rights reserved.
 * Copyright (c) 2003 Huston Franklin.  All rights reserved.
 *
 * The contents of this file are subject to the Blocks Public License (the
 * "License"); You may not use this file except in compliance with the License.
 *
 * You may obtain a copy of the License at http://www.beepcore.org/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied.  See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 */
package org.beepcore.beep.core;

/**
 * Represents received BEEP MSG messages. Provides methods to reply to
 * the MSG.
 *
 * @author Eric Dixon
 * @author Huston Franklin
 * @author Jay Kint
 * @author Scott Pead
 * @version $Revision: 1.1 $, $Date: 2003/06/03 16:38:35 $
 *
 */
class MessageMSGImpl extends MessageImpl implements MessageMSG
{
    MessageMSGImpl(ChannelImpl channel, int msgno, InputDataStream data) {
        super(channel, msgno, data, Message.MESSAGE_TYPE_MSG);
    }

    /**
     * Sends a message of type ANS.
     *
     * @param stream Data to send in the form of <code>OutputDataStream</code>.
     *
     * @see OutputDataStream
     * @see MessageStatus
     * @see #sendNUL
     *
     * @return MessageStatus
     *
     * @throws BEEPException if an error is encoutered.
     */
    public MessageStatus sendANS(OutputDataStream stream) throws BEEPException
    {
        MessageStatus m;

        synchronized (this) {
            // reusing ansno (initialized to -1) from Message since
            // this is a MSG
            ++ansno;

            m = new MessageStatus(this.channel, Message.MESSAGE_TYPE_ANS,
                                  this.msgno, this.ansno, stream);
        }

        this.channel.sendMessage(m);
        return m;
    }

    /**
     * Sends a message of type ERR.
     *
     * @param error Error to send in the form of <code>BEEPError</code>.
     *
     * @see BEEPError
     * @see MessageStatus
     *
     * @return MessageStatus
     *
     * @throws BEEPException if an error is encoutered.
     */
    public MessageStatus sendERR(BEEPError error) throws BEEPException
    {
        OutputDataStream stream =
            new StringOutputDataStream(error.createErrorMessage());
        MessageStatus m = new MessageStatus(this.channel,
                                            Message.MESSAGE_TYPE_ERR,
                                            this.msgno, stream);
        this.channel.sendMessage(m);
        return m;
    }

    /**
     * Sends a message of type ERR.
     *
     * @param code <code>code</code> attibute in <code>error</code> element.
     * @param diagnostic Message for <code>error</code> element.
     *
     * @see MessageStatus
     *
     * @return MessageStatus
     *
     * @throws BEEPException if an error is encoutered.
     */
    public MessageStatus sendERR(int code, String diagnostic)
        throws BEEPException
    {
        String error = BEEPError.createErrorMessage(code, diagnostic);
        MessageStatus m = new MessageStatus(this.channel,
                                            Message.MESSAGE_TYPE_ERR,
                                            this.msgno,
                                            new StringOutputDataStream(error));
        this.channel.sendMessage(m);
        return m;
    }

    /**
     * Sends a message of type ERR.
     *
     * @param code <code>code</code> attibute in <code>error</code> element.
     * @param diagnostic Message for <code>error</code> element.
     * @param xmlLang <code>xml:lang</code> attibute in <code>error</code>
     *                element.
     *
     * @see MessageStatus
     *
     * @return MessageStatus
     *
     * @throws BEEPException if an error is encoutered.
     */
    public MessageStatus sendERR(int code, String diagnostic, String xmlLang)
        throws BEEPException
    {
        String error = BEEPError.createErrorMessage(code, diagnostic, xmlLang);
        MessageStatus m = new MessageStatus(this.channel,
                                            Message.MESSAGE_TYPE_ERR,
                                            this.msgno,
                                            new StringOutputDataStream(error));
        this.channel.sendMessage(m);
        return m;
    }

    /**
     * Sends a message of type NUL.
     *
     * @see MessageStatus
     * @see #sendANS
     *
     * @return MessageStatus
     *
     * @throws BEEPException if an error is encoutered.
     */
    public MessageStatus sendNUL() throws BEEPException
    {
        MessageStatus m = new MessageStatus(this.channel,
                                            Message.MESSAGE_TYPE_NUL,
                                            this.msgno, NULDataStream);
        this.channel.sendMessage(m);
        return m;
    }

    /**
     * Sends a message of type RPY.
     *
     * @param stream Data to send in the form of <code>OutputDataStream</code>.
     *
     * @see OutputDataStream
     * @see MessageStatus
     *
     * @return MessageStatus
     *
     * @throws BEEPException if an error is encoutered.
     */
    public MessageStatus sendRPY(OutputDataStream stream) throws BEEPException
    {
        MessageStatus m = new MessageStatus(this.channel,
                                            Message.MESSAGE_TYPE_RPY,
                                            this.msgno, stream);
        this.channel.sendMessage(m);
        return m;
    }

    private static OutputDataStream NULDataStream;

    static {
        NULDataStream = new OutputDataStream();
        NULDataStream.setComplete();
    }

}

Index: Message.java
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/core/Message.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -r1.11 -r1.12
*** Message.java	23 Apr 2003 15:23:04 -0000	1.11
--- Message.java	3 Jun 2003 16:38:35 -0000	1.12
***************
*** 2,6 ****
   * Message.java            $Revision$ $Date$
   *
!  * Copyright (c) 2001 Invisible Worlds, Inc.  All rights reserved.
   *
   * The contents of this file are subject to the Blocks Public License (the
--- 2,6 ----
   * Message.java            $Revision$ $Date$
   *
!  * Copyright (c) 2003 Huston Franklin.  All rights reserved.
   *
   * The contents of this file are subject to the Blocks Public License (the
***************
*** 19,297 ****
  
  /**
!  * Message encapsulates the BEEP MSG, RPY, ERR and NUL message types.
   *
-  * @author Eric Dixon
   * @author Huston Franklin
-  * @author Jay Kint
-  * @author Scott Pead
   * @version $Revision$, $Date$
   */
! public class Message {
  
      /**
!      * Uninitialized BEEP message.
       */
      public static final int MESSAGE_TYPE_UNK = 0;
  
      /**
!      * BEEP message type.
       */
      public static final int MESSAGE_TYPE_MSG = 1;
  
      /**
!      * BEEP message type.
       */
      public static final int MESSAGE_TYPE_RPY = 2;
  
      /**
!      * BEEP message type.
       */
      public static final int MESSAGE_TYPE_ERR = 3;
  
      /**
!      * BEEP message type.
       */
      public static final int MESSAGE_TYPE_ANS = 4;
  
      /**
!      * BEEP message type.
       */
      public static final int MESSAGE_TYPE_NUL = 5;
  
-     /** BEEP message type of  <code>Message</code>. */
-     int messageType = MESSAGE_TYPE_UNK;
- 
-     /** <code>Channel</code> to which <code>Message</code> belongs. */
-     ChannelImpl channel;
- 
-     /** Message number of <code>Message</code>. */
-     int msgno;
- 
-     /** Answer number of this BEEP message. */
-     int ansno;
- 
-     /**
-      * BEEP message type for utility only.
-      */
-     private static final int MESSAGE_TYPE_MAX = 6;
- 
-     private static final String NOT_MESSAGE_TYPE_MSG =
-         "Message is not of type MSG";
- 
-     private boolean notified = false;
- 
-     /**
-      * Payload of the <code>Message</code> stored as a
-      * <code>InputDataStream</code>
-      *
-      * @see org.beepcore.beep.core.InputDataStream
-      */
-     private InputDataStream data;
- 
      /**
!      * Creates a new <code>Message</code>.
!      *
!      * @param channel <code>Channel</code> to which this <code>Message</code>
!      *    belongs.
!      * @param msgno Message number of the BEEP message.
!      * @param data  <code>InputDataStream</code> containing the payload of the
!      *    message.
!      * @param messageType Message type of the BEEP message.
       *
       * @see InputDataStream
-      * @see Channel
       */
!     Message(ChannelImpl channel, int msgno, InputDataStream data, int messageType)
!     {
!         this.channel = channel;
!         this.msgno = msgno;
!         this.ansno = -1;
!         this.data = data;
!         this.messageType = messageType;
!     }
  
      /**
!      * Creates a BEEP message of type ANS
!      *
!      * @param channel <code>Channel</code> to which the message belongs.
!      * @param msgno Message number of the message.
!      * @param ansno
!      * @param data  <code>InputDataStream</code> contains the payload of the
!      *    message.
       *
       * @see Channel
-      * @see InputDataStream
       */
!     Message(ChannelImpl channel, int msgno, int ansno, InputDataStream data)
!     {
!         this(channel, msgno, data, MESSAGE_TYPE_ANS);
! 
!         this.ansno = ansno;
!     }
! 
!     /**
!      * Returns <code>InputDataStream</code> belonging to <code>Message</code>.
!      *
!      * @see InputDataStream
!      */
!     public InputDataStream getDataStream()
!     {
!         return this.data;
!     }
! 
!     /**
!      * Returns the <code>Channel</code> to which this <code>Message</code>
!      * belongs.
!      *
!      * @see Channel
!      */
!     public Channel getChannel()
!     {
!         return this.channel;
!     }
  
      /**
       * Returns the message number of this <code>Message</code>.
       */
!     public int getMsgno()
!     {
!         return this.msgno;
!     }
  
      /**
       * Returns the answer number of this <code>Message</code>.
       */
!     public int getAnsno()
!     {
!         return this.ansno;
!     }
  
      /**
       * Returns the message type of this <code>Message</code>.
       */
!     public int getMessageType()
!     {
!         return this.messageType;
!     }
  
      /**
!      * Sends a message of type ANS.
!      *
!      * @param stream Data to send in the form of <code>OutputDataStream</code>.
!      *
!      * @see OutputDataStream
!      * @see MessageStatus
!      * @see #sendNUL
!      *
!      * @return MessageStatus
!      *
!      * @throws BEEPException if an error is encoutered or if messageType is
!      *         not MESSAGE_TYPE_MSG.
       */
!     public MessageStatus sendANS(OutputDataStream stream) throws BEEPException
!     {
!         throw new BEEPException(NOT_MESSAGE_TYPE_MSG);
!     }
  
      /**
!      * Sends a message of type ERR.
!      *
!      * @param error Error to send in the form of <code>BEEPError</code>.
!      *
!      * @see BEEPError
!      * @see MessageStatus
!      *
!      * @return MessageStatus
!      *
!      * @throws BEEPException if an error is encoutered or if messageType is
!      *         not MESSAGE_TYPE_MSG.
       */
!     public MessageStatus sendERR(BEEPError error) throws BEEPException
!     {
!         throw new BEEPException(NOT_MESSAGE_TYPE_MSG);
!     }
  
      /**
!      * Sends a message of type ERR.
!      *
!      * @param code <code>code</code> attibute in <code>error</code> element.
!      * @param diagnostic Message for <code>error</code> element.
!      *
!      * @see MessageStatus
!      *
!      * @return MessageStatus
!      *
!      * @throws BEEPException if an error is encoutered or if messageType is
!      *         not MESSAGE_TYPE_MSG.
       */
      public MessageStatus sendERR(int code, String diagnostic)
!         throws BEEPException
!     {
!         throw new BEEPException(NOT_MESSAGE_TYPE_MSG);
!     }
  
      /**
!      * Sends a message of type ERR.
!      *
!      * @param code <code>code</code> attibute in <code>error</code> element.
!      * @param diagnostic Message for <code>error</code> element.
!      * @param xmlLang <code>xml:lang</code> attibute in <code>error</code>
!      *                element.
!      *
!      * @see MessageStatus
!      *
!      * @return MessageStatus
!      *
!      * @throws BEEPException if an error is encoutered or if messageType is
!      *         not MESSAGE_TYPE_MSG.
       */
      public MessageStatus sendERR(int code, String diagnostic, String xmlLang)
!         throws BEEPException
!     {
!         throw new BEEPException(NOT_MESSAGE_TYPE_MSG);
!     }
  
      /**
!      * Sends a message of type NUL.
!      *
!      * @see MessageStatus
!      * @see #sendANS
!      *
!      * @return MessageStatus
!      *
!      * @throws BEEPException if an error is encoutered or if messageType is
!      *         not MESSAGE_TYPE_MSG.
       */
!     public MessageStatus sendNUL() throws BEEPException
!     {
!         throw new BEEPException(NOT_MESSAGE_TYPE_MSG);
!     }
  
      /**
!      * Sends a message of type RPY.
!      *
!      * @param stream Data to send in the form of <code>OutputDataStream</code>.
!      *
!      * @see OutputDataStream
!      * @see MessageStatus
!      *
!      * @return MessageStatus
!      *
!      * @throws BEEPException if an error is encoutered or if messageType is
!      *         not MESSAGE_TYPE_MSG.
       */
!     public MessageStatus sendRPY(OutputDataStream stream) throws BEEPException
!     {
!         throw new BEEPException(NOT_MESSAGE_TYPE_MSG);
!     }
! 
!     boolean isNotified()
!     {
!         return this.notified;
!     }
! 
!     void setNotified()
!     {
!         this.notified = true;
!     }
  }
--- 19,121 ----
  
  /**
!  * This interface represents the operations available for all types of
!  * messages.
   *
   * @author Huston Franklin
   * @version $Revision$, $Date$
   */
! public interface Message {
  
      /**
!      * Uninitialized <code>Message</code>.
       */
      public static final int MESSAGE_TYPE_UNK = 0;
  
      /**
!      * BEEP MSG message.
       */
      public static final int MESSAGE_TYPE_MSG = 1;
  
      /**
!      * BEEP RPY message.
       */
      public static final int MESSAGE_TYPE_RPY = 2;
  
      /**
!      * BEEP ERR message.
       */
      public static final int MESSAGE_TYPE_ERR = 3;
  
      /**
!      * BEEP ANS message.
       */
      public static final int MESSAGE_TYPE_ANS = 4;
  
      /**
!      * BEEP NUL message.
       */
      public static final int MESSAGE_TYPE_NUL = 5;
  
      /**
!      * Returns <code>InputDataStream</code> containing the payload for this
!      * <code>Message</code>.
       *
       * @see InputDataStream
       */
!     public InputDataStream getDataStream();
  
      /**
!      * Returns the <code>Channel</code> on which this <code>Message</code>
!      * was received.
       *
       * @see Channel
       */
!     public Channel getChannel();
  
      /**
       * Returns the message number of this <code>Message</code>.
       */
!     public int getMsgno();
  
      /**
       * Returns the answer number of this <code>Message</code>.
       */
!     public int getAnsno();
  
      /**
       * Returns the message type of this <code>Message</code>.
       */
!     public int getMessageType();
  
      /**
!      * @deprecated use method on MessageMSG instead.
       */
!     public MessageStatus sendANS(OutputDataStream stream) throws BEEPException;
  
      /**
!      * @deprecated use method on MessageMSG instead.
       */
!     public MessageStatus sendERR(BEEPError error) throws BEEPException;
  
      /**
!      * @deprecated use method on MessageMSG instead.
       */
      public MessageStatus sendERR(int code, String diagnostic)
!         throws BEEPException;
  
      /**
!      * @deprecated use method on MessageMSG instead.
       */
      public MessageStatus sendERR(int code, String diagnostic, String xmlLang)
!         throws BEEPException;
  
      /**
!      * @deprecated use method on MessageMSG instead.
       */
!     public MessageStatus sendNUL() throws BEEPException;
  
      /**
!      * @deprecated use method on MessageMSG instead.
       */
!     public MessageStatus sendRPY(OutputDataStream stream) throws BEEPException;
  }

Index: ChannelImpl.java
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/core/ChannelImpl.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** ChannelImpl.java	3 Jun 2003 02:33:21 -0000	1.5
--- ChannelImpl.java	3 Jun 2003 16:38:35 -0000	1.6
***************
*** 186,190 ****
          sentMSGQueue.add(new MessageStatus(this, Message.MESSAGE_TYPE_MSG, 0,
                                             null, rl));
!         recvMSGQueue.add(new MessageMSG(this, 0, null));
  
          state = STATE_ACTIVE;
--- 186,190 ----
          sentMSGQueue.add(new MessageStatus(this, Message.MESSAGE_TYPE_MSG, 0,
                                             null, rl));
!         recvMSGQueue.add(new MessageMSGImpl(this, 0, null));
  
          state = STATE_ACTIVE;
***************
*** 427,433 ****
  
              synchronized (recvMSGQueue) {
!                 MessageMSG m = null;
                  if (recvMSGQueue.size() != 0) {
!                     m = (MessageMSG) recvMSGQueue.getLast();
  
                      if (m.getMsgno() != frame.getMsgno()) {
--- 427,433 ----
  
              synchronized (recvMSGQueue) {
!                 MessageMSGImpl m = null;
                  if (recvMSGQueue.size() != 0) {
!                     m = (MessageMSGImpl) recvMSGQueue.getLast();
  
                      if (m.getMsgno() != frame.getMsgno()) {
***************
*** 452,457 ****
                  }
  
!                 m = new MessageMSG(this, frame.getMsgno(),
!                                     new InputDataStream(this));
  
                  m.setNotified();
--- 452,457 ----
                  }
  
!                 m = new MessageMSGImpl(this, frame.getMsgno(),
!                                        new InputDataStream(this));
  
                  m.setNotified();
***************
*** 491,495 ****
          }
  
!         Message m = null;
  
          // This frame must be for a reply (RPY, ERR, ANS, NUL)
--- 491,495 ----
          }
  
!         MessageImpl m = null;
  
          // This frame must be for a reply (RPY, ERR, ANS, NUL)
***************
*** 539,544 ****
              }
  
!             m = new Message(this, frame.getMsgno(), null,
!                             Message.MESSAGE_TYPE_NUL);
  
              mstatus.setMessageStatus(MessageStatus.MESSAGE_STATUS_RECEIVED_REPLY);
--- 539,544 ----
              }
  
!             m = new MessageImpl(this, frame.getMsgno(), null,
!                                 Message.MESSAGE_TYPE_NUL);
  
              mstatus.setMessageStatus(MessageStatus.MESSAGE_STATUS_RECEIVED_REPLY);
***************
*** 563,567 ****
  
                  while (i.hasNext()) {
!                     Message tmp = (Message) i.next();
  
                      if (tmp.getAnsno() == frame.getAnsno()) {
--- 563,567 ----
  
                  while (i.hasNext()) {
!                     MessageImpl tmp = (MessageImpl) i.next();
  
                      if (tmp.getAnsno() == frame.getAnsno()) {
***************
*** 575,580 ****
                  // add it to the queue
                  if (m == null) {
!                     m = new Message(this, frame.getMsgno(), frame.getAnsno(),
!                                     new InputDataStream(this));
  
                      if (!frame.isLast()) {
--- 575,581 ----
                  // add it to the queue
                  if (m == null) {
!                     m = new MessageImpl(this, frame.getMsgno(),
!                                         frame.getAnsno(),
!                                         new InputDataStream(this));
  
                      if (!frame.isLast()) {
***************
*** 590,596 ****
              synchronized (recvReplyQueue) {
                  if (recvReplyQueue.size() == 0) {
!                     m = new Message(this, frame.getMsgno(),
!                                     new InputDataStream(this),
!                                     frame.getMessageType());
  
                      if (frame.isLast() == false) {
--- 591,597 ----
              synchronized (recvReplyQueue) {
                  if (recvReplyQueue.size() == 0) {
!                     m = new MessageImpl(this, frame.getMsgno(),
!                                         new InputDataStream(this),
!                                         frame.getMessageType());
  
                      if (frame.isLast() == false) {
***************
*** 601,605 ****
                      // @todo sanity check: make sure this is the
                      // right Message
!                     m = (Message) recvReplyQueue.getFirst();
  
                      if (frame.isLast()) {
--- 602,606 ----
                      // @todo sanity check: make sure this is the
                      // right Message
!                     m = (MessageImpl) recvReplyQueue.getFirst();
  
                      if (frame.isLast()) {
***************
*** 813,822 ****
               status.getMessageType() == Message.MESSAGE_TYPE_NUL))
          {
!             MessageMSG m;
              synchronized (recvMSGQueue) {
                  recvMSGQueue.removeFirst();
  
                  if (recvMSGQueue.size() != 0) {
!                     m = (MessageMSG) recvMSGQueue.getFirst();
                      synchronized (m) {
                          m.setNotified();
--- 814,823 ----
               status.getMessageType() == Message.MESSAGE_TYPE_NUL))
          {
!             MessageMSGImpl m;
              synchronized (recvMSGQueue) {
                  recvMSGQueue.removeFirst();
  
                  if (recvMSGQueue.size() != 0) {
!                     m = (MessageMSGImpl) recvMSGQueue.getFirst();
                      synchronized (m) {
                          m.setNotified();

Index: MessageMSG.java
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/core/MessageMSG.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** MessageMSG.java	21 Apr 2003 15:09:10 -0000	1.9
--- MessageMSG.java	3 Jun 2003 16:38:35 -0000	1.10
***************
*** 2,6 ****
   * MessageMSG.java  $Revision$ $Date$
   *
!  * Copyright (c) 2001 Invisible Worlds, Inc.  All rights reserved.
   *
   * The contents of this file are subject to the Blocks Public License (the
--- 2,6 ----
   * MessageMSG.java  $Revision$ $Date$
   *
!  * Copyright (c) 2003 Huston Franklin.  All rights reserved.
   *
   * The contents of this file are subject to the Blocks Public License (the
***************
*** 18,69 ****
  
  /**
!  * Represents received BEEP MSG messages. Provides methods to reply to
!  * the MSG.
   *
-  * @author Eric Dixon
   * @author Huston Franklin
-  * @author Jay Kint
-  * @author Scott Pead
   * @version $Revision$, $Date$
   *
   */
! class MessageMSG extends Message
  {
-     MessageMSG(ChannelImpl channel, int msgno, InputDataStream data) {
-         super(channel, msgno, data, MESSAGE_TYPE_MSG);
-     }
- 
      /**
!      * Sends a message of type ANS.
       *
!      * @param stream Data to send in the form of <code>OutputDataStream</code>.
       *
       * @see OutputDataStream
       * @see MessageStatus
       * @see #sendNUL
-      *
-      * @return MessageStatus
-      *
-      * @throws BEEPException if an error is encoutered.
       */
!     public MessageStatus sendANS(OutputDataStream stream) throws BEEPException
!     {
!         MessageStatus m;
! 
!         synchronized (this) {
!             // reusing ansno (initialized to -1) from Message since
!             // this is a MSG
!             ++ansno;
! 
!             m = new MessageStatus(this.channel, MESSAGE_TYPE_ANS, this.msgno,
!                                   this.ansno, stream);
!         }
! 
!         this.channel.sendMessage(m);
!         return m;
!     }
  
      /**
!      * Sends a message of type ERR.
       *
       * @param error Error to send in the form of <code>BEEPError</code>.
--- 18,42 ----
  
  /**
!  * This interface represents the operations available for messages of type MSG.
   *
   * @author Huston Franklin
   * @version $Revision$, $Date$
   *
   */
! public interface MessageMSG extends Message
  {
      /**
!      * Sends an ANS reply to this MSG message.
       *
!      * @param stream Payload to be sent.
       *
       * @see OutputDataStream
       * @see MessageStatus
       * @see #sendNUL
       */
!     public MessageStatus sendANS(OutputDataStream stream) throws BEEPException;
  
      /**
!      * Sends an ERR reply to this MSG message.
       *
       * @param error Error to send in the form of <code>BEEPError</code>.
***************
*** 71,91 ****
       * @see BEEPError
       * @see MessageStatus
-      *
-      * @return MessageStatus
-      *
-      * @throws BEEPException if an error is encoutered.
       */
!     public MessageStatus sendERR(BEEPError error) throws BEEPException
!     {
!         OutputDataStream stream =
!             new StringOutputDataStream(error.createErrorMessage());
!         MessageStatus m = new MessageStatus(this.channel, MESSAGE_TYPE_ERR,
!                                             this.msgno, stream);
!         this.channel.sendMessage(m);
!         return m;
!     }
  
      /**
!      * Sends a message of type ERR.
       *
       * @param code <code>code</code> attibute in <code>error</code> element.
--- 44,52 ----
       * @see BEEPError
       * @see MessageStatus
       */
!     public MessageStatus sendERR(BEEPError error) throws BEEPException;
  
      /**
!      * Sends an ERR reply to this MSG message.
       *
       * @param code <code>code</code> attibute in <code>error</code> element.
***************
*** 93,114 ****
       *
       * @see MessageStatus
-      *
-      * @return MessageStatus
-      *
-      * @throws BEEPException if an error is encoutered.
       */
      public MessageStatus sendERR(int code, String diagnostic)
!         throws BEEPException
!     {
!         String error = BEEPError.createErrorMessage(code, diagnostic);
!         MessageStatus m = new MessageStatus(this.channel, MESSAGE_TYPE_ERR,
!                                             this.msgno,
!                                             new StringOutputDataStream(error));
!         this.channel.sendMessage(m);
!         return m;
!     }
  
      /**
!      * Sends a message of type ERR.
       *
       * @param code <code>code</code> attibute in <code>error</code> element.
--- 54,63 ----
       *
       * @see MessageStatus
       */
      public MessageStatus sendERR(int code, String diagnostic)
!         throws BEEPException;
  
      /**
!      * Sends an ERR reply to this MSG message.
       *
       * @param code <code>code</code> attibute in <code>error</code> element.
***************
*** 120,139 ****
       *
       * @return MessageStatus
-      *
-      * @throws BEEPException if an error is encoutered.
       */
      public MessageStatus sendERR(int code, String diagnostic, String xmlLang)
!         throws BEEPException
!     {
!         String error = BEEPError.createErrorMessage(code, diagnostic, xmlLang);
!         MessageStatus m = new MessageStatus(this.channel, MESSAGE_TYPE_ERR,
!                                             this.msgno,
!                                             new StringOutputDataStream(error));
!         this.channel.sendMessage(m);
!         return m;
!     }
  
      /**
!      * Sends a message of type NUL.
       *
       * @see MessageStatus
--- 69,79 ----
       *
       * @return MessageStatus
       */
      public MessageStatus sendERR(int code, String diagnostic, String xmlLang)
!         throws BEEPException;
  
      /**
!      * Sends a reply of type NUL to this MSG message. This is sent as the
!      * completion to a MSG/ANS/NUL message exchange.
       *
       * @see MessageStatus
***************
*** 141,159 ****
       *
       * @return MessageStatus
-      *
-      * @throws BEEPException if an error is encoutered.
       */
!     public MessageStatus sendNUL() throws BEEPException
!     {
!         MessageStatus m = new MessageStatus(this.channel, MESSAGE_TYPE_NUL,
!                                             this.msgno, NULDataStream);
!         this.channel.sendMessage(m);
!         return m;
!     }
  
      /**
!      * Sends a message of type RPY.
       *
!      * @param stream Data to send in the form of <code>OutputDataStream</code>.
       *
       * @see OutputDataStream
--- 81,91 ----
       *
       * @return MessageStatus
       */
!     public MessageStatus sendNUL() throws BEEPException;
  
      /**
!      * Sends a RPY reply to this MSG message.
       *
!      * @param stream Payload to be sent.
       *
       * @see OutputDataStream
***************
*** 161,181 ****
       *
       * @return MessageStatus
-      *
-      * @throws BEEPException if an error is encoutered.
       */
!     public MessageStatus sendRPY(OutputDataStream stream) throws BEEPException
!     {
!         MessageStatus m = new MessageStatus(this.channel, MESSAGE_TYPE_RPY,
!                                             this.msgno, stream);
!         this.channel.sendMessage(m);
!         return m;
!     }
! 
!     private static OutputDataStream NULDataStream;
! 
!     static {
!         NULDataStream = new OutputDataStream();
!         NULDataStream.setComplete();
!     }
! 
  }
--- 93,97 ----
       *
       * @return MessageStatus
       */
!     public MessageStatus sendRPY(OutputDataStream stream) throws BEEPException;
  }

Index: SessionImpl.java
===================================================================
RCS file: /cvsroot/beepcore-java/beepcore-java/src/org/beepcore/beep/core/SessionImpl.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** SessionImpl.java	3 Jun 2003 02:33:21 -0000	1.6
--- SessionImpl.java	3 Jun 2003 16:38:35 -0000	1.7
***************
*** 1345,1349 ****
                                       greeting);
  
!         Message m = new MessageMSG(this.zero, 0, null);
  
          // send the greeting
--- 1345,1349 ----
                                       greeting);
  
!         MessageMSG m = new MessageMSGImpl(this.zero, 0, null);
  
          // send the greeting



-------------------------------------------------------
This SF.net email is sponsored by: eBay
Get office equipment for less on eBay!
http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5