1 /* 2 Copyright 2010 Ramon Servadei 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 package mirrormap.nio; 17 18 import mirrormap.lifecycle.IDestroyable; 19 20 /** 21 * Handles data received from a remote {@link IConnectionEndPoint}. 22 * Implementations should be efficient as the {@link #receive(byte[])} method 23 * may tie up the thread handling the socket receive operations. 24 * <p> 25 * There should only be 1 receiver instance per end point. 26 * 27 * @author Ramon Servadei 28 */ 29 public interface IConnectionEndPointReceiver extends IDestroyable 30 { 31 /** 32 * Factory that creates {@link IConnectionEndPointReceiver} instances 33 * 34 * @author Ramon Servadei 35 */ 36 public interface IFactory 37 { 38 /** 39 * Create the {@link IConnectionEndPointReceiver} 40 * 41 * @return a new {@link IConnectionEndPointReceiver} 42 */ 43 IConnectionEndPointReceiver createEndPointRecevier(); 44 } 45 46 /** 47 * Handle data received from the remote end point. 48 * 49 * @param data 50 * the data 51 */ 52 void receive(byte[] data); 53 54 /** 55 * The end point this receiver is associated with. 56 * 57 * @param connectionEndPoint 58 * the end point this receiver is for 59 */ 60 void setEndPointConnection(IConnectionEndPoint connectionEndPoint); 61 }