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    package org.apache.directory.server.protocol.shared;
020    
021    
022    import org.apache.directory.server.core.DirectoryService;
023    import org.apache.directory.server.protocol.shared.transport.Transport;
024    import org.apache.mina.transport.socket.DatagramAcceptor;
025    import org.apache.mina.transport.socket.SocketAcceptor;
026    
027    
028    /**
029     * Minimum functionality required by an ApacheDS protocol service.
030     *
031     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
032     * @version $Rev$, $Date$
033     */
034    public interface ProtocolService
035    {
036        /**
037         * Stops this ProtocolService which unbinds acceptors on the protocol port.
038         *
039         * @throws Exception if there are problems stopping this service
040         */
041        void stop() throws Exception;
042    
043    
044        /**
045         * Starts this ProtocolService which binds acceptors on the protocol port.
046         *
047         * @throws Exception if there are problems starting this service
048         */
049        void start() throws Exception;
050    
051    
052        /**
053         * Gets whether or not this service has been started.
054         *
055         * @return true if the service has started, false otherwise
056         */
057        boolean isStarted();
058    
059    
060        /**
061         * If this protocol service supports UDP transport then this gets the
062         * non-null MINA DatagramAcceptor it uses.
063         *
064         * @return the MINA DatagramAcceptor used for UDP transports
065         */
066        DatagramAcceptor getDatagramAcceptor( Transport transport );
067    
068    
069        /**
070         * If this protocol service support TCP transport then this gets the
071         * MINA SocketAcceptor it uses.
072         *
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    
128    
129        /**
130         * Gets the DirectoryService assigned to this ProtocolService.
131         *
132         * @return the directory service core assigned to this service
133         */
134        DirectoryService getDirectoryService();
135    
136    
137        /**
138         * Sets the DirectoryService assigned to this ProtocolService.
139         *
140         * @param directoryService the directory service core assigned to this service
141         */
142        void setDirectoryService( DirectoryService directoryService );
143    }