KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > quickserver > net > server > impl > RegisterChannelRequest


1 /*
2  * This file is part of the QuickServer library
3  * Copyright (C) QuickServer.org
4  *
5  * Use, modification, copying and distribution of this software is subject to
6  * the terms and conditions of the GNU Lesser General Public License.
7  * You should have received a copy of the GNU LGP License along with this
8  * library; if not, you can download a copy from <http://www.quickserver.org/>.
9  *
10  * For questions, suggestions, bug-reports, enhancement-requests etc.
11  * visit http://www.quickserver.org
12  *
13  */

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 /**
22  * RegisterChannel request object.
23  * @author Akshathkumar Shetty
24  * @since 1.4.7
25  */

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 JavaDoc att;
32
33     public RegisterChannelRequest(SelectableChannel channel, int ops, Object JavaDoc 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 JavaDoc getAtt() {
64         return att;
65     }
66
67     public void setAtt(Object JavaDoc att) {
68         this.att = att;
69     }
70
71     public boolean equals(Object JavaDoc 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