1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 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.api; 21 22 import java.util.Map; 23 24 import org.apache.mina.service.executor.IoHandlerExecutor; 25 26 /** 27 * Base interface for all {@link IoServer}s and {@link IoClient}s that provide I/O service and manage {@link IoSession} 28 * s. 29 * 30 * @author <a href="http://mina.apache.org">Apache MINA Project</a> 31 */ 32 public interface IoService { 33 /** 34 * Returns the map of all sessions which are currently managed by this service. The key of map is the 35 * {@link IoSession#getId() ID} of the session. 36 * 37 * @return the sessions. An empty collection if there's no session. 38 */ 39 Map<Long, IoSession> getManagedSessions(); 40 41 /** 42 * Set the {@link IoHandler} in charge of your business logic for this service. 43 * 44 * @param handler the handler called for every event of the service (new connections, messages received, etc..) 45 */ 46 void setIoHandler(IoHandler handler); 47 48 /** 49 * Get the {@link IoHandler} in charge of your business logic for this service. 50 * 51 * @return the handler called for every event of the service (new connections, messages received, etc..) 52 */ 53 IoHandler getIoHandler(); 54 55 /** 56 * Get the {@link IoHandlerExecutor} used for executing {@link IoHandler} events in another pool of thread (not in 57 * the low level I/O one). 58 */ 59 IoHandlerExecutor getIoHandlerExecutor(); 60 61 /** 62 * Get the list of filters installed on this service 63 * 64 * @return The list of installed filters 65 */ 66 IoFilter[] getFilters(); 67 68 /** 69 * Set the list of filters for this service. Must be called before the service is bound/connected 70 * 71 * @param The list of filters to inject in the filters chain 72 */ 73 void setFilters(IoFilter... filters); 74 75 /** 76 * Returns the default configuration of the new {@link IoSession}s created by this service. 77 * 78 * @return The default configuration for this {@link IoService} 79 */ 80 IoSessionConfig getSessionConfig(); 81 }