01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: *
19: */
20: package org.apache.mina.common;
21:
22: import org.apache.mina.common.IoFilter.NextFilter;
23:
24: /**
25: * An I/O event or an I/O request that MINA provides for {@link IoFilter}s.
26: * Most users won't need to use this class. It is usually used by internal
27: * components to store I/O events.
28: *
29: * @author The Apache MINA Project (dev@mina.apache.org)
30: * @version $Rev: 591770 $, $Date: 2007-11-04 05:22:44 -0700 (Sun, 04 Nov 2007) $
31: */
32: public class IoFilterEvent extends IoEvent {
33:
34: private final NextFilter nextFilter;
35:
36: public IoFilterEvent(NextFilter nextFilter, IoEventType type,
37: IoSession session, Object parameter) {
38: super (type, session, parameter);
39:
40: if (nextFilter == null) {
41: throw new NullPointerException("nextFilter");
42: }
43: this .nextFilter = nextFilter;
44: }
45:
46: public NextFilter getNextFilter() {
47: return nextFilter;
48: }
49:
50: @Override
51: public void fire() {
52: switch (getType()) {
53: case MESSAGE_RECEIVED:
54: getNextFilter().messageReceived(getSession(),
55: getParameter());
56: break;
57: case MESSAGE_SENT:
58: getNextFilter().messageSent(getSession(),
59: (WriteRequest) getParameter());
60: break;
61: case WRITE:
62: getNextFilter().filterWrite(getSession(),
63: (WriteRequest) getParameter());
64: break;
65: case SET_TRAFFIC_MASK:
66: getNextFilter().filterSetTrafficMask(getSession(),
67: (TrafficMask) getParameter());
68: break;
69: case CLOSE:
70: getNextFilter().filterClose(getSession());
71: break;
72: case EXCEPTION_CAUGHT:
73: getNextFilter().exceptionCaught(getSession(),
74: (Throwable) getParameter());
75: break;
76: case SESSION_IDLE:
77: getNextFilter().sessionIdle(getSession(),
78: (IdleStatus) getParameter());
79: break;
80: case SESSION_OPENED:
81: getNextFilter().sessionOpened(getSession());
82: break;
83: case SESSION_CREATED:
84: getNextFilter().sessionCreated(getSession());
85: break;
86: case SESSION_CLOSED:
87: getNextFilter().sessionClosed(getSession());
88: break;
89: default:
90: throw new IllegalArgumentException("Unknown event type: "
91: + getType());
92: }
93: }
94: }
|