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 import java.net.URI; 21 22 23 /*** 24 * A SynchChannelFilter can be used as a filter another {@see org.activeio.SynchChannel} 25 * Most {@see org.activeio.SynchChannel} that are not directly accessing the network will 26 * extends the SynchChannelFilter since they act as a filter between the client and the network. 27 * 28 * @version $Revision$ 29 */ 30 public class FilterSynchChannelServer implements SynchChannelServer { 31 32 private final SynchChannelServer next; 33 34 public FilterSynchChannelServer(SynchChannelServer next) { 35 this.next = next; 36 } 37 38 /*** 39 * @see org.activeio.Disposable#dispose() 40 */ 41 public void dispose() { 42 next.dispose(); 43 } 44 45 /*** 46 * @see org.activeio.Service#start() 47 */ 48 public void start() throws IOException { 49 next.start(); 50 } 51 52 /*** 53 * @see org.activeio.Service#stop(long) 54 */ 55 public void stop(long timeout) throws IOException { 56 next.stop(timeout); 57 } 58 59 /*** 60 * @return Returns the next. 61 */ 62 public SynchChannelServer getNext() { 63 return next; 64 } 65 66 /*** 67 * @see org.activeio.SynchChannelServer#accept(long) 68 */ 69 public Channel accept(long timeout) throws IOException { 70 return next.accept(timeout); 71 } 72 73 /*** 74 * @see org.activeio.ChannelServer#getBindURI() 75 */ 76 public URI getBindURI() { 77 return next.getBindURI(); 78 } 79 80 /*** 81 * @see org.activeio.ChannelServer#getConnectURI() 82 */ 83 public URI getConnectURI() { 84 return next.getConnectURI(); 85 } 86 87 public Object narrow(Class target) { 88 if( target.isAssignableFrom(getClass()) ) { 89 return this; 90 } 91 return next.narrow(target); 92 } 93 94 public String toString() { 95 return next.toString(); 96 } 97 }