Coverage Report - com.sun.grizzly.async.AsyncQueueWritable
 
Classes in this File Line Coverage Branch Coverage Complexity
AsyncQueueWritable
N/A
N/A
1
 
 1  
 /*
 2  
  * 
 3  
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 4  
  * 
 5  
  * Copyright 2007-2008 Sun Microsystems, Inc. All rights reserved.
 6  
  * 
 7  
  * The contents of this file are subject to the terms of either the GNU
 8  
  * General Public License Version 2 only ("GPL") or the Common Development
 9  
  * and Distribution License("CDDL") (collectively, the "License").  You
 10  
  * may not use this file except in compliance with the License. You can obtain
 11  
  * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
 12  
  * or glassfish/bootstrap/legal/LICENSE.txt.  See the License for the specific
 13  
  * language governing permissions and limitations under the License.
 14  
  * 
 15  
  * When distributing the software, include this License Header Notice in each
 16  
  * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
 17  
  * Sun designates this particular file as subject to the "Classpath" exception
 18  
  * as provided by Sun in the GPL Version 2 section of the License file that
 19  
  * accompanied this code.  If applicable, add the following below the License
 20  
  * Header, with the fields enclosed by brackets [] replaced by your own
 21  
  * identifying information: "Portions Copyrighted [year]
 22  
  * [name of copyright owner]"
 23  
  * 
 24  
  * Contributor(s):
 25  
  * 
 26  
  * If you wish your version of this file to be governed by only the CDDL or
 27  
  * only the GPL Version 2, indicate your decision by adding "[Contributor]
 28  
  * elects to include this software in this distribution under the [CDDL or GPL
 29  
  * Version 2] license."  If you don't indicate a single choice of license, a
 30  
  * recipient has the option to distribute your version of this file under
 31  
  * either the CDDL, the GPL Version 2 or to extend the choice of license to
 32  
  * its licensees as provided above.  However, if you add GPL Version 2 code
 33  
  * and therefore, elected the GPL Version 2 license, then the option applies
 34  
  * only if the new code is made subject to such option by the copyright
 35  
  * holder.
 36  
  *
 37  
  */
 38  
 
 39  
 
 40  
 package com.sun.grizzly.async;
 41  
 
 42  
 import java.io.IOException;
 43  
 import java.net.SocketAddress;
 44  
 import java.nio.ByteBuffer;
 45  
 
 46  
 /**
 47  
  * Object, which is able to send {@link ByteBuffer} data asynchronously,
 48  
  * using queue.
 49  
  * 
 50  
  * @author Alexey Stashok
 51  
  */
 52  
 public interface AsyncQueueWritable {
 53  
     /**
 54  
      * Method writes {@link ByteBuffer} using async write queue.
 55  
      * First, if write queue is empty - it tries to write {@link ByteBuffer}
 56  
      * directly (without putting to the queue).
 57  
      * If associated write queue is not empty or after direct writing 
 58  
      * {@link ByteBuffer} still has ready data to be written - 
 59  
      * {@link ByteBuffer} will be added to {@link AsyncQueue}.
 60  
      * If an exception occurs, during direct writing - it will be propagated 
 61  
      * to the caller directly, otherwise it will be just logged by 
 62  
      * Grizzly framework.
 63  
      * 
 64  
      * @param buffer {@link ByteBuffer}
 65  
      * @throws java.io.IOException
 66  
      */
 67  
     public void writeToAsyncQueue(ByteBuffer buffer) throws IOException;
 68  
     
 69  
     /**
 70  
      * Method writes {@link ByteBuffer} using async write queue.
 71  
      * First, if write queue is empty - it tries to write {@link ByteBuffer}
 72  
      * directly (without putting to the queue).
 73  
      * If associated write queue is not empty or after direct writing 
 74  
      * {@link ByteBuffer} still has ready data to be written - 
 75  
      * {@link ByteBuffer} will be added to {@link AsyncQueue}.
 76  
      * If an exception occurs, during direct writing - it will be propagated 
 77  
      * to the caller directly, otherwise, if the {@link ByteBuffer} is 
 78  
      * added to a writing queue - exception notification will come via 
 79  
      * <code>AsyncWriteCallbackHandler.onIOException()</code>
 80  
      * 
 81  
      * @param buffer {@link ByteBuffer}
 82  
      * @param callbackHandler {@link AsyncWriteCallbackHandler}, 
 83  
      *                        which will get notified, when 
 84  
      *                        {@link ByteBuffer} will be completely written
 85  
      * @throws java.io.IOException
 86  
      */
 87  
     public void writeToAsyncQueue(ByteBuffer buffer, 
 88  
             AsyncWriteCallbackHandler callbackHandler) throws IOException;
 89  
 
 90  
     /**
 91  
      * Method writes {@link ByteBuffer} using async write queue.
 92  
      * First, if write queue is empty - it tries to write {@link ByteBuffer}
 93  
      * directly (without putting to the queue).
 94  
      * If associated write queue is not empty or after direct writing 
 95  
      * {@link ByteBuffer} still has ready data to be written - 
 96  
      * {@link ByteBuffer} will be added to {@link AsyncQueue}.
 97  
      * If an exception occurs, during direct writing - it will be propagated 
 98  
      * to the caller directly, otherwise, if the {@link ByteBuffer} is 
 99  
      * added to a writing queue - exception notification will come via 
 100  
      * <code>AsyncWriteCallbackHandler.onIOException()</code>
 101  
      * Before data will be written on {@link SelectableChannel}, first it
 102  
      * will be passed for preprocessing to <code>AsyncQueueDataProcessor</code>,
 103  
      * and then preprocessor result data 
 104  
      * (<code>AsyncQueueDataProcessor.getResultByteBuffer()</code>) will be 
 105  
      * written on the {@link SelectableChannel}.
 106  
      * 
 107  
      * @param buffer {@link ByteBuffer}
 108  
      * @param callbackHandler {@link AsyncWriteCallbackHandler}, 
 109  
      *                        which will get notified, when 
 110  
      *                        {@link ByteBuffer} will be completely written
 111  
      * @param writePreProcessor <code>AsyncQueueDataProcessor</code>, which
 112  
      *                        will perform data processing, before it will be 
 113  
      *                        written on {@link SelectableChannel}
 114  
      * @throws java.io.IOException
 115  
      */
 116  
     public void writeToAsyncQueue(ByteBuffer buffer, 
 117  
             AsyncWriteCallbackHandler callbackHandler,
 118  
             AsyncQueueDataProcessor writePreProcessor) throws IOException;
 119  
 
 120  
     /**
 121  
      * Method writes {@link ByteBuffer} using async write queue.
 122  
      * First, if write queue is empty - it tries to write {@link ByteBuffer}
 123  
      * directly (without putting to the queue).
 124  
      * If associated write queue is not empty or after direct writing 
 125  
      * {@link ByteBuffer} still has ready data to be written - 
 126  
      * {@link ByteBuffer} will be added to {@link AsyncQueue}.
 127  
      * If an exception occurs, during direct writing - it will be propagated 
 128  
      * to the caller directly, otherwise, if the {@link ByteBuffer} is 
 129  
      * added to a writing queue - exception notification will come via 
 130  
      * <code>AsyncWriteCallbackHandler.onIOException()</code>
 131  
      * Before data will be written on {@link SelectableChannel}, first it
 132  
      * will be passed for preprocessing to <code>AsyncQueueDataProcessor</code>,
 133  
      * and then preprocessor result data 
 134  
      * (<code>AsyncQueueDataProcessor.getResultByteBuffer()</code>) will be 
 135  
      * written on the {@link SelectableChannel}.
 136  
      * 
 137  
      * @param buffer {@link ByteBuffer}
 138  
      * @param callbackHandler {@link AsyncWriteCallbackHandler}, 
 139  
      *                        which will get notified, when 
 140  
      *                        {@link ByteBuffer} will be completely written
 141  
      * @param writePreProcessor <code>AsyncQueueDataProcessor</code>, which
 142  
      *                        will perform data processing, before it will be 
 143  
      *                        written on {@link SelectableChannel}
 144  
      * @param isCloneByteBuffer if true - {@link AsyncQueueWriter} 
 145  
      *                          will clone given
 146  
      *                          {@link ByteBuffer} before puting it to the 
 147  
      *                          {@link AsyncQueue}
 148  
      * @throws java.io.IOException
 149  
      */
 150  
     public void writeToAsyncQueue(ByteBuffer buffer, 
 151  
             AsyncWriteCallbackHandler callbackHandler, 
 152  
             AsyncQueueDataProcessor writePreProcessor,
 153  
             boolean isCloneByteBuffer) throws IOException;
 154  
 
 155  
     /**
 156  
      * Method sends {@link ByteBuffer} using async write queue.
 157  
      * First, if write queue is empty - it tries to send {@link ByteBuffer}
 158  
      * to the given {@link SocketAddress} directly 
 159  
      * (without putting to the queue).
 160  
      * If associated write queue is not empty or after direct sending 
 161  
      * {@link ByteBuffer} still has ready data to be written - 
 162  
      * {@link ByteBuffer} will be added to {@link AsyncQueue}.
 163  
      * If an exception occurs, during direct writing - it will be propagated 
 164  
      * to the caller directly, otherwise it will be just logged by 
 165  
      * Grizzly framework.
 166  
      * 
 167  
      * @param dstAddress destination {@link SocketAddress} data will 
 168  
      *                   be sent to
 169  
      * @param buffer {@link ByteBuffer}
 170  
      * @throws java.io.IOException
 171  
      */
 172  
     public void writeToAsyncQueue(SocketAddress dstAddress, ByteBuffer buffer)
 173  
             throws IOException;
 174  
     
 175  
     /**
 176  
      * Method sends {@link ByteBuffer} using async write queue.
 177  
      * First, if write queue is empty - it tries to send {@link ByteBuffer}
 178  
      * to the given {@link SocketAddress} directly 
 179  
      * (without putting to the queue).
 180  
      * If associated write queue is not empty or after direct sending 
 181  
      * {@link ByteBuffer} still has ready data to be written - 
 182  
      * {@link ByteBuffer} will be added to {@link AsyncQueue}.
 183  
      * If an exception occurs, during direct writing - it will be propagated 
 184  
      * to the caller directly, otherwise, if the {@link ByteBuffer} is 
 185  
      * added to a writing queue - exception notification will come via 
 186  
      * <code>AsyncWriteCallbackHandler.onIOException()</code>
 187  
      * 
 188  
      * @param dstAddress destination {@link SocketAddress} data will 
 189  
      *                   be sent to
 190  
      * @param buffer {@link ByteBuffer}
 191  
      * @param callbackHandler {@link AsyncWriteCallbackHandler}, 
 192  
      *                        which will get notified, when 
 193  
      *                        {@link ByteBuffer} will be completely written
 194  
      * @throws java.io.IOException
 195  
      */
 196  
     public void writeToAsyncQueue(SocketAddress dstAddress, ByteBuffer buffer, 
 197  
             AsyncWriteCallbackHandler callbackHandler) throws IOException;
 198  
 
 199  
     /**
 200  
      * Method sends {@link ByteBuffer} using async write queue.
 201  
      * First, if write queue is empty - it tries to send {@link ByteBuffer}
 202  
      * to the given {@link SocketAddress} directly 
 203  
      * (without putting to the queue).
 204  
      * If associated write queue is not empty or after direct sending 
 205  
      * {@link ByteBuffer} still has ready data to be written - 
 206  
      * {@link ByteBuffer} will be added to {@link AsyncQueue}.
 207  
      * If an exception occurs, during direct writing - it will be propagated 
 208  
      * to the caller directly, otherwise, if the {@link ByteBuffer} is 
 209  
      * added to a writing queue - exception notification will come via 
 210  
      * <code>AsyncWriteCallbackHandler.onIOException()</code>
 211  
      * Before data will be written on {@link SelectableChannel}, first it
 212  
      * will be passed for preprocessing to <code>AsyncQueueDataProcessor</code>,
 213  
      * and then preprocessor result data 
 214  
      * (<code>AsyncQueueDataProcessor.getResultByteBuffer()</code>) will be 
 215  
      * written on the {@link SelectableChannel}.
 216  
      * 
 217  
      * @param dstAddress destination {@link SocketAddress} data will 
 218  
      *                   be sent to
 219  
      * @param buffer {@link ByteBuffer}
 220  
      * @param callbackHandler {@link AsyncWriteCallbackHandler}, 
 221  
      *                        which will get notified, when 
 222  
      *                        {@link ByteBuffer} will be completely written
 223  
      * @param writePreProcessor <code>AsyncQueueDataProcessor</code>, which
 224  
      *                        will perform data processing, before it will be 
 225  
      *                        written on {@link SelectableChannel}
 226  
      * @throws java.io.IOException
 227  
      */
 228  
     public void writeToAsyncQueue(SocketAddress dstAddress, ByteBuffer buffer, 
 229  
             AsyncWriteCallbackHandler callbackHandler,
 230  
             AsyncQueueDataProcessor writePreProcessor) throws IOException;
 231  
 
 232  
     /**
 233  
      * Method sends {@link ByteBuffer} using async write queue.
 234  
      * First, if write queue is empty - it tries to send {@link ByteBuffer}
 235  
      * to the given {@link SocketAddress} directly 
 236  
      * (without putting to the queue).
 237  
      * If associated write queue is not empty or after direct sending 
 238  
      * {@link ByteBuffer} still has ready data to be written - 
 239  
      * {@link ByteBuffer} will be added to {@link AsyncQueue}.
 240  
      * If an exception occurs, during direct writing - it will be propagated 
 241  
      * to the caller directly, otherwise, if the {@link ByteBuffer} is 
 242  
      * added to a writing queue - exception notification will come via 
 243  
      * <code>AsyncWriteCallbackHandler.onIOException()</code>
 244  
      * Before data will be written on {@link SelectableChannel}, first it
 245  
      * will be passed for preprocessing to <code>AsyncQueueDataProcessor</code>,
 246  
      * and then preprocessor result data 
 247  
      * (<code>AsyncQueueDataProcessor.getResultByteBuffer()</code>) will be 
 248  
      * written on the {@link SelectableChannel}.
 249  
      * 
 250  
      * @param dstAddress destination {@link SocketAddress} data will 
 251  
      *                   be sent to
 252  
      * @param buffer {@link ByteBuffer}
 253  
      * @param callbackHandler {@link AsyncWriteCallbackHandler}, 
 254  
      *                        which will get notified, when 
 255  
      *                        {@link ByteBuffer} will be completely written
 256  
      * @param writePreProcessor <code>AsyncQueueDataProcessor</code>, which
 257  
      *                        will perform data processing, before it will be 
 258  
      *                        written on {@link SelectableChannel}
 259  
      * @param isCloneByteBuffer if true - {@link AsyncQueueWriter} 
 260  
      *                          will clone given
 261  
      *                          {@link ByteBuffer} before puting it to the 
 262  
      *                          {@link AsyncQueue}
 263  
      * @throws java.io.IOException
 264  
      */
 265  
     public void writeToAsyncQueue(SocketAddress dstAddress, ByteBuffer buffer, 
 266  
             AsyncWriteCallbackHandler callbackHandler, 
 267  
             AsyncQueueDataProcessor writePreProcessor,
 268  
             boolean isCloneByteBuffer) throws IOException;
 269  
 }