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 */ 019package org.apache.directory.server.protocol.shared; 020 021 022import org.apache.directory.server.protocol.shared.transport.Transport; 023import org.apache.mina.transport.socket.DatagramAcceptor; 024import org.apache.mina.transport.socket.SocketAcceptor; 025 026 027/** 028 * Minimum functionality required by an ApacheDS protocol service. 029 * 030 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 031 */ 032public interface ProtocolService 033{ 034 /** 035 * Stops this ProtocolService which unbinds acceptors on the protocol port. 036 * 037 * @throws Exception if there are problems stopping this service 038 */ 039 void stop() throws Exception; 040 041 042 /** 043 * Starts this ProtocolService which binds acceptors on the protocol port. 044 * 045 * @throws Exception if there are problems starting this service 046 */ 047 void start() throws Exception; 048 049 050 /** 051 * Gets whether or not this service has been started. 052 * 053 * @return true if the service has started, false otherwise 054 */ 055 boolean isStarted(); 056 057 058 /** 059 * If this protocol service supports UDP transport then this gets the 060 * non-null MINA DatagramAcceptor it uses. 061 * 062 * @param transport The Transport we are interested in 063 * @return the MINA DatagramAcceptor used for UDP transports 064 */ 065 DatagramAcceptor getDatagramAcceptor( Transport transport ); 066 067 068 /** 069 * If this protocol service support TCP transport then this gets the 070 * MINA SocketAcceptor it uses. 071 * 072 * @param transport The Transport we are interested in 073 * @return the MINA SocketAcceptor used for TCP transport 074 */ 075 SocketAcceptor getSocketAcceptor( Transport transport ); 076 077 078 /** 079 * Services can be enabled or disabled. If enabled they will be started, if 080 * not they will not. 081 * 082 * @return true if this service is to be started, false otherwise 083 */ 084 boolean isEnabled(); 085 086 087 /** 088 * Sets whether or not this ProtocolService is enabled. 089 * 090 * @param enabled true to enable, false to disable 091 */ 092 void setEnabled( boolean enabled ); 093 094 095 /** 096 * Gets the instance identifier for this ProtocolService. 097 * 098 * @return the identifier for the service instance 099 */ 100 String getServiceId(); 101 102 103 /** 104 * Sets the instance identifier for this ProtocolService. 105 * 106 * @param serviceId an identifier for the service instance 107 */ 108 void setServiceId( String serviceId ); 109 110 111 /** 112 * Gets a descriptive name for the kind of service this represents. 113 * This name is constant across instances of this ProtocolService. 114 * 115 * @return a descriptive name for the kind of this service 116 */ 117 String getServiceName(); 118 119 120 /** 121 * Sets the descriptive name for the kind of service this represents. 122 * This name is constant across instances of this ProtocolService. 123 * 124 * @param name a descriptive name for the kind of this service 125 */ 126 void setServiceName( String name ); 127}