##### Coverage Report - com.sun.grizzly.async.AsyncQueueReadable

Classes in this File | Line Coverage | Branch Coverage | Complexity
AsyncQueueReadable |
N/A | N/A
N/A | N/A
| 1.0;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.nio.ByteBuffer;
44 |  |
45 |  |
     /**
46 |  |
      * Object, which is able to read data to the {@link ByteBuffer}
47 |  |
      * asynchronously, using queue.
48 |  |
      *
49 |  |
      * @author Alexey Stashok
50 |  |
      */
51 |  |
     public interface AsyncQueueReadable {
52 |  |
         /**
53 |  |
          * Method reads data to the {@link ByteBuffer} using async read queue.
54 |  |
          * First, if read queue is empty - it tries to read to the
55 |  |
          * {@link ByteBuffer} directly (without putting to the queue).
56 |  |
          * If associated read queue is not empty or after direct reading
57 |  |
          * {@link ByteBuffer} still has remaining place for next read -
58 |  |
          * {@link ByteBuffer} will be added to {@link AsyncQueue}.
59 |  |
          * If an exception occurs, during direct reading - it will be propagated
60 |  |
          * to the caller directly, otherwise, if the {@link ByteBuffer} is
61 |  |
          * added to a reading queue - exception notification will come via
62 |  |
          * <code>AsyncReadCallbackHandler.onIOException()</code>
63 |  |
          *
64 |  |
          * @param buffer {@link ByteBuffer}
65 |  |
          * @param callbackHandler {@link AsyncReadCallbackHandler},
66 |  |
          *                        which will get notified, when
67 |  |
          *                        {@link ByteBuffer} will get full
68 |  |
          * @return true, if {@link ByteBuffer} was read completely,
69 |  |
          *         false if read operation was put to queue
70 |  |
          * @throws java.io.IOException
71 |  |
          */
72 |  |
         public void readFromAsyncQueue(ByteBuffer buffer,
73 |  |
                 AsyncReadCallbackHandler callbackHandler) throws IOException;
74 |  |
75 |  |
         /**
76 |  |
          * Method reads data to the {@link ByteBuffer} using async read queue.
77 |  |
          * First, if read queue is empty - it tries to read to the
78 |  |
          * {@link ByteBuffer} directly (without putting to the queue).
79 |  |
          * If associated read queue is not empty or after direct reading
80 |  |
          * {@link ByteBuffer} still has remaining place for next read -
81 |  |
          * {@link ByteBuffer} will be added to {@link AsyncQueue}.
82 |  |
          * If an exception occurs, during direct reading - it will be propagated
83 |  |
          * to the caller directly, otherwise, if the {@link ByteBuffer} is
84 |  |
          * added to a reading queue - exception notification will come via
85 |  |
          * <code>AsyncReadCallbackHandler.onIOException()</code>
86 |  |
          *
87 |  |
          * @param buffer {@link ByteBuffer}
88 |  |
          * @param callbackHandler {@link AsyncReadCallbackHandler},
89 |  |
          *                        which will get notified, when
90 |  |
          *                        {@link ByteBuffer} will get full
91 |  |
          * @param condition {@link AsyncReadCondition}, which will be called to
92 |  |
          *                  check if read data is complete, and callbackHandler could
93 |  |
          *                  be called
94 |  |
          * @return true, if {@link ByteBuffer} was read completely,
95 |  |
          *         false if read operation was put to queue
96 |  |
          * @throws java.io.IOException
97 |  |
          */
98 |  |
         public void readFromAsyncQueue(ByteBuffer buffer,
99 |  |
                 AsyncReadCallbackHandler callbackHandler,
100 |  |
                 AsyncReadCondition condition) throws IOException;
101 |  |
102 |  |
         /**
103 |  |
          * Method reads data to the {@link ByteBuffer} using async read queue.
104 |  |
          * First, if read queue is empty - it tries to read to the
105 |  |
          * {@link ByteBuffer} directly (without putting to the queue).
106 |  |
          * If associated read queue is not empty or after direct reading
107 |  |
          * {@link ByteBuffer} still has remaining place for next read -
108 |  |
          * {@link ByteBuffer} will be added to {@link AsyncQueue}.
109 |  |
          * If an exception occurs, during direct reading - it will be propagated
110 |  |
          * to the caller directly, otherwise, if the {@link ByteBuffer} is
111 |  |
          * added to a reading queue - exception notification will come via
112 |  |
          * <code>AsyncReadCallbackHandler.onIOException()</code>
113 |  |
          *
114 |  |
          * @param buffer {@link ByteBuffer}
115 |  |
          * @param callbackHandler {@link AsyncReadCallbackHandler},
116 |  |
          *                        which will get notified, when
117 |  |
          *                        {@link ByteBuffer} will get full
118 |  |
          * @param condition {@link AsyncReadCondition}, which will be called to
119 |  |
          *                  check if read data is complete, and callbackHandler could
120 |  |
          *                  be called
121 |  |
          * @param readPostProcessor post processor, to be called to process read data
122 |  |
          *
123 |  |
          * @return true, if {@link ByteBuffer} was read completely,
124 |  |
          *         false if read operation was put to queue
125 |  |
          * @throws java.io.IOException
126 |  |
          */
127 |  |
         public void readFromAsyncQueue(ByteBuffer buffer,
128 |  |
                 AsyncReadCallbackHandler callbackHandler,
129 |  |
                 AsyncReadCondition condition,
130 |  |
                 AsyncQueueDataProcessor readPostProcessor) throws IOException;
131 |  |
     }