    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.wiki.api.spi;
    020
    021import org.apache.wiki.api.core.Command;
    022import org.apache.wiki.api.core.Context;
    023import org.apache.wiki.api.core.Engine;
    024import org.apache.wiki.api.core.Page;
    025
    026import javax.servlet.http.HttpServletRequest;
    027
    028
    029/**
    030 * SPI used to locate and provide {@link Context} instances.
    031 */
    032public interface ContextSPI {
    033
    034    /**
    035     *  Create a new Context for the given Page.
    036     *
    037     *  @param engine The Engine that is handling the request.
    038     *  @param page The Page. If you want to create a Context for an older version of a page, you must use this method.
    039     */
    040    Context create( Engine engine, Page page );
    041
    042    /**
    043     * <p>Creates a new Context for the given Engine, Command and HttpServletRequest.</p>
    044     * <p>This constructor will also look up the HttpSession associated with the request, and determine if a Session object is present.
    045     * If not, a new one is created.</p>
    046     *
    047     * @param engine The Engine that is handling the request
    048     * @param request The HttpServletRequest that should be associated with this context. This parameter may be <code>null</code>.
    049     * @param command the command
    050     */
    051    Context create( Engine engine, HttpServletRequest request, Command command );
    052
    053    /**
    054     * Creates a new Context for the given Engine, Page and HttpServletRequest.
    055     *
    056     * @param engine The Engine that is handling the request
    057     * @param request The HttpServletRequest that should be associated with this context. This parameter may be <code>null</code>.
    058     * @param page The WikiPage. If you want to create a WikiContext for an older version of a page, you must supply this parameter
    059     */
    060    Context create( Engine engine, HttpServletRequest request, Page page );
    061
    062    /**
    063     *  Creates a new Context from a supplied HTTP request, using a default wiki context.
    064     *
    065     *  @param engine The Engine that is handling the request
    066     *  @param request the HTTP request
    067     *  @param requestContext the default context to use
    068     */
    069    Context create( Engine engine, HttpServletRequest request, String requestContext );
    070
    071}