View Javadoc

1   /*
2    * $Id: ActionMapper.java 651946 2008-04-27 13:41:38Z apetrelli $
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  
22  package org.apache.struts2.dispatcher.mapper;
23  
24  import javax.servlet.http.HttpServletRequest;
25  
26  import com.opensymphony.xwork2.config.ConfigurationManager;
27  
28  /***
29   * <!-- START SNIPPET: javadoc -->
30   *
31   * The ActionMapper interface provides a mapping between HTTP requests and action invocation requests and vice-versa.
32   * <p/>
33   * When given an HttpServletRequest, the ActionMapper may return null if no action invocation request matches,
34   * or it may return an {@link ActionMapping} that describes an action invocation for the framework to try.
35   * <p/>
36   * The ActionMapper is not required to guarantee that the {@link ActionMapping} returned be a real action or otherwise
37   * ensure a valid request.
38   * Accordingly, most ActionMappers do not need to consult the Struts configuration
39   * just to determine if a request should be mapped.
40   * <p/>
41   * Just as requests can be mapped from HTTP to an action invocation, the opposite is true as well.
42   * However, because HTTP requests (when shown in HTTP responses) must be in String form,
43   * a String is returned rather than an actual request object.
44   *
45   * <!-- END SNIPPET: javadoc -->
46   */
47  public interface ActionMapper {
48  
49      /***
50       * Expose the ActionMapping for the current request
51       *
52       * @param request The servlet request
53       * @param configManager The current configuration manager
54       * @return The appropriate action mapping
55       */
56      ActionMapping getMapping(HttpServletRequest request, ConfigurationManager configManager);
57  
58      /***
59       * Expose the ActionMapping for the specified action name
60       *
61       * @param actionName The name of the action that may have other information embedded in it
62       * @return The appropriate action mapping
63       * @since 2.1.1
64       */
65      ActionMapping getMappingFromActionName(String actionName);
66  
67      /***
68       * Convert an ActionMapping into a URI string
69       *
70       * @param mapping The action mapping
71       * @return The URI string that represents this mapping
72       */
73      String getUriFromActionMapping(ActionMapping mapping);
74  }