01: /*
02: * This file is part of the QuickServer library
03: * Copyright (C) QuickServer.org
04: *
05: * Use, modification, copying and distribution of this software is subject to
06: * the terms and conditions of the GNU Lesser General Public License.
07: * You should have received a copy of the GNU LGP License along with this
08: * library; if not, you can download a copy from <http://www.quickserver.org/>.
09: *
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
28: .getLogger(RegisterChannelRequest.class.getName());
29:
30: private SelectableChannel channel;
31: private int ops;
32: private Object att;
33:
34: public RegisterChannelRequest(SelectableChannel channel, int ops,
35: Object att) {
36: this .channel = channel;
37: this .ops = ops;
38: this .att = att;
39: }
40:
41: public void register(Selector selector) {
42: try {
43: channel.register(selector, ops, att);
44: } catch (ClosedChannelException cce) {
45: logger.warning("Error: " + cce);
46: }
47: }
48:
49: public SelectableChannel getChannel() {
50: return channel;
51: }
52:
53: public void setChannel(SelectableChannel channel) {
54: this .channel = channel;
55: }
56:
57: public int getOps() {
58: return ops;
59: }
60:
61: public void setOps(int ops) {
62: this .ops = ops;
63: }
64:
65: public Object getAtt() {
66: return att;
67: }
68:
69: public void setAtt(Object att) {
70: this .att = att;
71: }
72:
73: public boolean equals(Object obj) {
74: if (obj == null)
75: return false;
76:
77: RegisterChannelRequest req = (RegisterChannelRequest) obj;
78: boolean res = req.getChannel() == getChannel();
79: if (res)
80: res = req.getAtt() == getAtt();
81: if (res)
82: res = req.getOps() == getOps();
83: return res;
84: }
85: }
|