View Javadoc

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