cedric      2002/12/29 13:27:32

  Modified:    src/share/org/apache/struts/util RequestUtils.java
  Log:
  Add two methods:
   - one to retrieve the module config from the request
   - one to get the module name from a uri passed as String
  
  Revision  Changes    Path
  1.77      +31 -4     
jakarta-struts/src/share/org/apache/struts/util/RequestUtils.java
  
  Index: RequestUtils.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/util/RequestUtils.java,v
  retrieving revision 1.76
  retrieving revision 1.77
  diff -u -r1.76 -r1.77
  --- RequestUtils.java 29 Dec 2002 16:59:58 -0000      1.76
  +++ RequestUtils.java 29 Dec 2002 21:27:32 -0000      1.77
  @@ -1618,6 +1618,7 @@
        * Get the module name to which the specified request belong.
        * @param request The servlet request we are processing
        * @param context The ServletContext for this web application
  +     * @return The module prefix or ""
        */
       public static String getModuleName(HttpServletRequest request, ServletContext 
context) {
   
  @@ -1627,7 +1628,16 @@
           if (matchPath == null) {
               matchPath = request.getServletPath();
           }
  +        return getModuleName( matchPath, context);
  +    }
   
  +    /**
  +     * Get the module name to which the specified uri belong.
  +     * @param matchPath The uri from which we want the module name.
  +     * @param context The ServletContext for this web application
  +     * @return The module prefix or ""
  +     */
  +    public static String getModuleName(String matchPath, ServletContext context) {
           if (log.isDebugEnabled()) {
               log.debug("Get module name for path " + matchPath);
           }
  @@ -1670,6 +1680,23 @@
                   (ModuleConfig) 
pageContext.getServletContext().getAttribute(Globals.MODULE_KEY);
           }
           return moduleConfig;
  +    }
  +
  +    /**
  +     * Return the current ModuleConfig object stored in request, if it exists,
  +     * null otherwise.
  +     * This method can be used by plugin to retrieve the current module config
  +     * object. If no moduleConfig is found, this means that the request haven't
  +     * hit the server throught the struts servlet. The appropriate module config
  +     * can be set and found with
  +     * <code>{@link RequestUtils.selectModule(request, servletContext)} </code>.
  +     * @param request The servlet request we are processing
  +     * @return the ModuleConfig object from request, or null if none is set in
  +     * the request.
  +     * @since 1.1b3
  +     */
  +    public static ModuleConfig getRequestModuleConfig( HttpServletRequest request) {
  +        return (ModuleConfig) request.getAttribute(Globals.MODULE_KEY);
       }
   
       /**
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to