1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 package nginx.unit.websocket; 18 19 import java.nio.ByteBuffer; 20 import java.nio.channels.CompletionHandler; 21 import java.util.concurrent.Future; 22 import java.util.concurrent.TimeUnit; 23 24 import javax.net.ssl.SSLException; 25 26 /** 27 * This is a wrapper for a {@link java.nio.channels.AsynchronousSocketChannel} 28 * that limits the methods available thereby simplifying the process of 29 * implementing SSL/TLS support since there are fewer methods to intercept. 30 */ 31 public interface AsyncChannelWrapper { 32 read(ByteBuffer dst)33 Future<Integer> read(ByteBuffer dst); 34 read(ByteBuffer dst, A attachment, CompletionHandler<Integer,B> handler)35 <B,A extends B> void read(ByteBuffer dst, A attachment, 36 CompletionHandler<Integer,B> handler); 37 write(ByteBuffer src)38 Future<Integer> write(ByteBuffer src); 39 write(ByteBuffer[] srcs, int offset, int length, long timeout, TimeUnit unit, A attachment, CompletionHandler<Long,B> handler)40 <B,A extends B> void write(ByteBuffer[] srcs, int offset, int length, 41 long timeout, TimeUnit unit, A attachment, 42 CompletionHandler<Long,B> handler); 43 close()44 void close(); 45 handshake()46 Future<Void> handshake() throws SSLException; 47 } 48