1 14 15 package org.quickserver.net.server.impl; 16 17 import java.io.*; 18 import java.util.logging.*; 19 import java.nio.channels.*; 20 21 26 public class RegisterChannelRequest { 27 private static final Logger logger = Logger.getLogger(RegisterChannelRequest.class.getName()); 28 29 private SelectableChannel channel; 30 private int ops; 31 private Object att; 32 33 public RegisterChannelRequest(SelectableChannel channel, int ops, Object att) { 34 this.channel = channel; 35 this.ops = ops; 36 this.att = att; 37 } 38 39 public void register(Selector selector) { 40 try { 41 channel.register(selector, ops, att); 42 } catch(ClosedChannelException cce) { 43 logger.warning("Error: "+cce); 44 } 45 } 46 47 public SelectableChannel getChannel() { 48 return channel; 49 } 50 51 public void setChannel(SelectableChannel channel) { 52 this.channel = channel; 53 } 54 55 public int getOps() { 56 return ops; 57 } 58 59 public void setOps(int ops) { 60 this.ops = ops; 61 } 62 63 public Object getAtt() { 64 return att; 65 } 66 67 public void setAtt(Object att) { 68 this.att = att; 69 } 70 71 public boolean equals(Object obj) { 72 if(obj==null) return false; 73 74 RegisterChannelRequest req = (RegisterChannelRequest) obj; 75 boolean res = req.getChannel()==getChannel(); 76 if(res) res = req.getAtt()==getAtt(); 77 if(res) res = req.getOps()==getOps(); 78 return res; 79 } 80 } | Popular Tags |