View Javadoc

    1   /*
    2    * $Id: ActionMapper.java 474787 2006-11-14 13:51:15Z husted $
    3    *
    4    * Licensed to the Apache Software Foundation (ASF) under one
    5    * or more contributor license agreements.  See the NOTICE file
    6    * distributed with this work for additional information
    7    * regarding copyright ownership.  The ASF licenses this file
    8    * to you under the Apache License, Version 2.0 (the
    9    * "License"); you may not use this file except in compliance
    10   * with the License.  You may obtain a copy of the License at
    11   *
    12   *  http://www.apache.org/licenses/LICENSE-2.0
    13   *
    14   * Unless required by applicable law or agreed to in writing,
    15   * software distributed under the License is distributed on an
    16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    17   * KIND, either express or implied.  See the License for the
    18   * specific language governing permissions and limitations
    19   * under the License.
    20   */
    21  package org.apache.struts2.dispatcher.mapper;
    22
    23  import javax.servlet.http.HttpServletRequest;
    24
    25  import com.opensymphony.xwork2.config.ConfigurationManager;
    26
    27  /***
    28   * <!-- START SNIPPET: javadoc -->
    29   *
    30   * Provide a mapping between HTTP requests and action invocation requests and vice-versa.
    31   * <p/>
    32   * When given an HttpServletRequest, the ActionMapper may return null if no action invocation request matches,
    33   * or it may return an {@link ActionMapping} that describes an action invocation for the framework to try.
    34   * <p/>
    35   * The ActionMapper is not required to guarantee that the {@link ActionMapping} returned be a real action or otherwise
    36   * ensure a valid request.
    37   * Accordingly, most ActionMappers do not need to consult the Struts configuration
    38   * just to determine if a request should be mapped.
    39   * <p/>
    40   * Just as requests can be mapped from HTTP to an action invocation, the opposite is true as well.
    41   * However, because HTTP requests (when shown in HTTP responses) must be in String form,
    42   * a String is returned rather than an actual request object.
    43   *
    44   * <!-- END SNIPPET: javadoc -->
    45   */
    46  public interface ActionMapper {
    47
    48      /***
    49       * Expose the ActionMapping for the current request
    50       *
    51       * @param request The servlet request
    52       * @param configManager The current configuration manager
    53       * @return The appropriate action mapping
    54       */
    55      ActionMapping getMapping(HttpServletRequest request, ConfigurationManager configManager);
    56
    57      /***
    58       * Convert an ActionMapping into a URI string
    59       *
    60       * @param mapping The action mapping
    61       * @return The URI string that represents this mapping
    62       */
    63      String getUriFromActionMapping(ActionMapping mapping);
    64  }