001/*
002 * Copyright 2012-2015 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.boot.context.embedded;
018
019/**
020 * Simple interface that represents a fully configured embedded servlet container (for
021 * example Tomcat or Jetty). Allows the container to be {@link #start() started} and
022 * {@link #stop() stopped}.
023 * <p>
024 * Instances of this class are usually obtained via a
025 * {@link EmbeddedServletContainerFactory}.
026 *
027 * @author Phillip Webb
028 * @author Dave Syer
029 * @see EmbeddedServletContainerFactory
030 */
031public interface EmbeddedServletContainer {
032
033        /**
034         * Starts the embedded servlet container. Calling this method on an already started
035         * container has no effect.
036         * @throws EmbeddedServletContainerException if the container cannot be started
037         */
038        void start() throws EmbeddedServletContainerException;
039
040        /**
041         * Stops the embedded servlet container. Calling this method on an already stopped
042         * container has no effect.
043         * @throws EmbeddedServletContainerException if the container cannot be stopped
044         */
045        void stop() throws EmbeddedServletContainerException;
046
047        /**
048         * Return the port this server is listening on.
049         * @return the port (or -1 if none)
050         */
051        int getPort();
052
053}