1 /*** 2 * 3 * Copyright 2004 Hiram Chirino 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * 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 org.activeio; 18 19 import java.io.IOException; 20 21 22 /*** 23 * A SynchChannelFilter can be used as a filter another {@see org.activeio.SynchChannel} 24 * Most {@see org.activeio.SynchChannel} that are not directly accessing the network will 25 * extends the SynchChannelFilter since they act as a filter between the client and the network. 26 * 27 * @version $Revision$ 28 */ 29 public class FilterSynchChannel implements SynchChannel { 30 31 private final SynchChannel next; 32 33 public FilterSynchChannel(SynchChannel next) { 34 this.next = next; 35 } 36 37 /*** 38 * @see org.activeio.Channel#write(org.activeio.channel.Packet) 39 */ 40 public void write(Packet packet) throws IOException { 41 next.write(packet); 42 } 43 44 /*** 45 * @see org.activeio.Channel#flush() 46 */ 47 public void flush() throws IOException { 48 next.flush(); 49 } 50 51 /*** 52 * @see org.activeio.Disposable#dispose() 53 */ 54 public void dispose() { 55 next.dispose(); 56 } 57 58 /*** 59 * @see org.activeio.Service#start() 60 */ 61 public void start() throws IOException { 62 next.start(); 63 } 64 65 /*** 66 * @see org.activeio.Service#stop(long) 67 */ 68 public void stop(long timeout) throws IOException { 69 next.stop(timeout); 70 } 71 72 /*** 73 * @return Returns the next. 74 */ 75 public SynchChannel getNext() { 76 return next; 77 } 78 79 /*** 80 * @see org.activeio.SynchChannel#read(long) 81 */ 82 public Packet read(long timeout) throws IOException { 83 return next.read(timeout); 84 } 85 86 public Object narrow(Class target) { 87 if( target.isAssignableFrom(getClass()) ) { 88 return this; 89 } 90 return next.narrow(target); 91 } 92 93 public String toString() { 94 return next.toString(); 95 } 96 }