Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source
   * Copyright 2011, JBoss Inc., and individual contributors as indicated
   * by the @authors tag. See the copyright.txt in the distribution for a
   * full listing of individual contributors.
   *
   * This is free software; you can redistribute it and/or modify it
   * under the terms of the GNU Lesser General Public License as
   * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
 
 package org.jboss.remoting3;
 
The most basic level of communications in a Remoting connection. A channel simply sends and receives messages. No request/reply correlation is performed. Messages are received in the order that they are written; however, multiple messages may flow in or out concurrently on a single channel. In particular, a later message may complete before an earlier message does.

Author(s):
David M. Lloyd
 
 public interface Channel extends AttachableHandleableCloseable<Channel>, Configurable {

    
Get the connection associated with this channel.

Returns:
the connection
 
     Connection getConnection();

    
Write a new message on to this channel, blocking if necessary.

Returns:
the outbound message to send
Throws:
java.io.IOException if a new message cannot be written
 
     MessageOutputStream writeMessage() throws IOException;

    
Send an end-of-messages signal to the remote side. No more messages may be written after this method is called; however, more incoming messages may be received.

Throws:
java.io.IOException if the message could not be written
 
     void writeShutdown() throws IOException;

    
Initiate processing of the next message, when it comes in. This method does not block; instead the handler is called asynchronously (possibly in another thread) if/when the next message arrives.

Parameters:
handler the handler for the next incoming message
 
     void receiveMessage(Receiver handler);

    
Determine whether an option is supported on this channel.

Parameters:
option the option
Returns:
true if it is supported
 
     boolean supportsOption(Option<?> option);

    
Get the value of a channel option.

Parameters:
<T> the type of the option value
option the option to get
Returns:
the value of the option, or null if it is not set
 
     <T> T getOption(Option<T> option);

    
Set an option for this channel. Unsupported options are ignored.

Parameters:
<T> the type of the option value
option the option to set
value the value of the option to set
Returns:
the previous option value, if any
Throws:
java.lang.IllegalArgumentException if the value is not acceptable for this option
 
    <T> T setOption(Option<T> option, T valuethrows IllegalArgumentException;

    
Close this channel. No more messages may be sent or received after this method is called.

Throws:
java.io.IOException if a failure occurs during close
    void close() throws IOException;

    
A handler for an incoming message.
    interface Receiver {

        
Handle an error condition on the channel. The channel will no longer be readable.

Parameters:
channel the channel
error the error condition
        void handleError(Channel channelIOException error);

        
Handle an end-of-input condition on a channel. The channel will no longer be readable.

Parameters:
channel the channel
        void handleEnd(Channel channel);

        
Handle an incoming message. To receive further messages, the Channel.receiveMessage(org.jboss.remoting3.Channel.Receiver) method must be called again.

Parameters:
channel the channel
message the message
        void handleMessage(Channel channelMessageInputStream message);
    }
New to GrepCode? Check out our FAQ X