    001    package org.apache.turbine.services.servlet;
    002
    003
    004    /*
    005     * Licensed to the Apache Software Foundation (ASF) under one
    006     * or more contributor license agreements.  See the NOTICE file
    007     * distributed with this work for additional information
    008     * regarding copyright ownership.  The ASF licenses this file
    009     * to you under the Apache License, Version 2.0 (the
    010     * "License"); you may not use this file except in compliance
    011     * with the License.  You may obtain a copy of the License at
    012     *
    013     *   http://www.apache.org/licenses/LICENSE-2.0
    014     *
    015     * Unless required by applicable law or agreed to in writing,
    016     * software distributed under the License is distributed on an
    017     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    018     * KIND, either express or implied.  See the License for the
    019     * specific language governing permissions and limitations
    020     * under the License.
    021     */
    022
    023
    024    import java.io.InputStream;
    025    import java.net.URL;
    026
    027    import javax.servlet.ServletConfig;
    028    import javax.servlet.ServletContext;
    029
    030    import org.apache.turbine.services.Service;
    031
    032    /**
    033     * <p>This interface exposes methods of the runner context in order
    034     * resolve or get access to external resources</p>
    035     *
    036     * @author <a href="mailto:ekkerbj@netscape.net">Jeff Brekke</a>
    037     * @author <a href="mailto:raphael@apache.org">Raphaël Luta</a>
    038     * @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
    039     * @version $Id: ServletService.java 1071044 2011-02-15 20:47:31Z tv $
    040     */
    041    public interface ServletService extends Service
    042    {
    043        /**
    044         * The service identifier
    045         */
    046        String SERVICE_NAME = "ServletService";
    047
    048        /**
    049         * Returns an URL object for a given URI string.
    050         *
    051         * @param uri the URI to resolve as an URL
    052         * @return an URL object or null is the uri is malformed or
    053         * can't be resolved
    054         */
    055        URL getResource(String uri);
    056
    057        /**
    058         * Same as getResource except that it returns an InputStream
    059         *
    060         * @param uri the URI to resolve
    061         * @return an InputStream on the URI content or null
    062         */
    063        InputStream getResourceAsStream(String uri);
    064
    065        /**
    066         * Returns the complete filesystem path for a
    067         * given URI
    068         *
    069         * @param uri the URI to resolve
    070         * @return the full system path of this URI
    071         */
    072        String getRealPath(String uri);
    073
    074        /**
    075         * Returns the servlet config used by this
    076         * Turbine web application.
    077         *
    078         * @return turbine servlet config
    079         */
    080        ServletConfig getServletConfig();
    081
    082        /**
    083         * Returns the servlet context used by this
    084         * Turbine web application.
    085         *
    086         * @return turbine servlet context
    087         */
    088        ServletContext getServletContext();
    089
    090        /**
    091         * Returns the server scheme for this
    092         * Turbine application. This will either
    093         * be http or https.
    094         *
    095         * @return String
    096         */
    097        String getServerScheme();
    098
    099        /**
    100         * Returns the server name that this
    101         * Turbine application is running
    102         * on.
    103         *
    104         * @return String
    105         */
    106        String getServerName();
    107
    108        /**
    109         * Returns the port that this Turbine
    110         * application is running through
    111         * on the server.
    112         *
    113         * @return String
    114         */
    115        String getServerPort();
    116
    117        /**
    118         * Returns the context path for this
    119         * Turbine application.
    120         *
    121         * @return String
    122         */
    123        String getContextPath();
    124    }