001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020package org.apache.mina.filter.executor; 021 022import java.util.EventListener; 023 024import org.apache.mina.core.session.IoEvent; 025 026/** 027 * Listens and filters all event queue operations occurring in 028 * {@link OrderedThreadPoolExecutor} and {@link UnorderedThreadPoolExecutor}. 029 * 030 * @author <a href="http://mina.apache.org">Apache MINA Project</a> 031 */ 032public interface IoEventQueueHandler extends EventListener { 033 034 /** 035 * A dummy handler which always accepts event doing nothing particular. 036 */ 037 IoEventQueueHandler NOOP = new IoEventQueueHandler() { 038 public boolean accept(Object source, IoEvent event) { 039 return true; 040 } 041 042 public void offered(Object source, IoEvent event) { 043 // NOOP 044 } 045 046 public void polled(Object source, IoEvent event) { 047 // NOOP 048 } 049 }; 050 051 /** 052 * @return <tt>true</tt> if and only if the specified <tt>event</tt> is 053 * allowed to be offered to the event queue. The <tt>event</tt> is dropped 054 * if <tt>false</tt> is returned. 055 * 056 * @param source The source of event 057 * @param event The received event 058 */ 059 boolean accept(Object source, IoEvent event); 060 061 /** 062 * Invoked after the specified <tt>event</tt> has been offered to the 063 * event queue. 064 * 065 * @param source The source of event 066 * @param event The received event 067 */ 068 void offered(Object source, IoEvent event); 069 070 /** 071 * Invoked after the specified <tt>event</tt> has been polled from the 072 * event queue. 073 * 074 * @param source The source of event 075 * @param event The received event 076 */ 077 void polled(Object source, IoEvent event); 078}