Package org.apache.struts.config

Examples of org.apache.struts.config.ModuleConfig


    public static String getActionMappingURL(ServletContext application,
                                             HttpServletRequest request,
                                             String action)
    {
        StringBuilder value = new StringBuilder(request.getContextPath());
        ModuleConfig config =
            (ModuleConfig)request.getAttribute(Globals.MODULE_KEY);
        if (config != null)
        {
            value.append(config.getPrefix());
        }

        /* Use our servlet mapping, if one is specified */
        String servletMapping =
            (String)application.getAttribute(Globals.SERVLET_KEY);
View Full Code Here


     */
    public static String getForwardURL(HttpServletRequest request,
                                       ServletContext app,
                                       String forward)
    {
        ModuleConfig moduleConfig = ModuleUtils.getInstance().getModuleConfig(request, app);
        //TODO? beware of null module config if ActionServlet isn't init'ed?

        ActionConfig actionConfig =
            (ActionConfig)request.getAttribute(Globals.MAPPING_KEY);

        // NOTE: ActionConfig.findForwardConfig only searches local forwards
        ForwardConfig fc = null;
        if(actionConfig != null)
        {
            fc = actionConfig.findForwardConfig(forward);
        }

        // No ActionConfig forward?
        // Find the ForwardConfig in the global-forwards.
        if(fc == null)
        {
            fc = moduleConfig.findForwardConfig(forward);

            // ok, give up
            if (fc == null)
            {
                return null;
View Full Code Here

        return null;
    }
   
    PageFlowRequestProcessor getRequestProcessor()
    {
        ModuleConfig mc = getModuleConfig();
        String key = Globals.REQUEST_PROCESSOR_KEY + mc.getPrefix();
        RequestProcessor rp = ( RequestProcessor ) getServletContext().getAttribute( key );
       
        //
        // The RequestProcessor may not have been initialized -- if so, just return a new (temporary) one.
        //
        if ( rp == null )
        {
            try
            {
                ControllerConfig cc = mc.getControllerConfig();
                rp = ( RequestProcessor ) RequestUtils.applicationInstance( cc.getProcessorClass() );
                rp.init( InternalUtils.getActionServlet( getServletContext() ), mc );
            }
            catch ( Exception e )
            {
                _log.error( "Could not initialize request processor for module " + mc.getPrefix(), e );
            }
        }
       
        assert rp == null || rp instanceof PageFlowRequestProcessor : rp.getClass().getName();
        return ( PageFlowRequestProcessor ) rp;
View Full Code Here

        _flowController = fc;
        _servletContext = fc.getServletContext();
       
        if ( _mapping == null && _mappingPath != null )
        {
            ModuleConfig mc = fc.getModuleConfig();
            assert mc != null : "no ModuleConfig found for " + fc.getClass().getName();
            _mapping = ( ActionMapping ) mc.findActionConfig( _mappingPath );
        }
    }
View Full Code Here

                    //
                    // First, see if the current module is a Shared Flow module.  If so, unless this is a forward to
                    // another action in the shared flow, we need to translate the local path so it makes sense (strip
                    // off the shared flow module prefix "/-" and replace it with "/").
                    //
                    ModuleConfig mc = ( ModuleConfig ) request.getAttribute( Globals.MODULE_KEY );

                    if ( InternalUtils.isSharedFlowModule( mc ) && ! fwdURI.endsWith( ACTION_EXTENSION )
                         && fwdURI.startsWith( SHARED_FLOW_MODULE_PREFIX ) )
                    {
                        fwdURI = '/' + fwdURI.substring( SHARED_FLOW_MODULE_PREFIX_LEN );
View Full Code Here

            PageFlowRequestWrapper rw = PageFlowRequestWrapper.unwrap( request );
            boolean isForwardedRequest = rw != null && rw.isForwardedRequest();
           
            try
            {
                ModuleConfig prevModuleConfig = RequestUtils.getRequestModuleConfig( httpRequest );
                MessageResources prevMessageResources = ( MessageResources ) request.getAttribute( Globals.MESSAGES_KEY );
                if ( rw == null || ! rw.isStayInCurrentModule() ) initializeModule( httpRequest, httpResponse );
               
                try
                {
View Full Code Here

        {
            AutoRegisterActionServlet das = ( AutoRegisterActionServlet ) as;
            das.ensureModuleRegistered( curModulePath, request );
        }
               
        ModuleConfig mc = InternalUtils.selectModule( curModulePath, request, _servletContext );
                   
        if ( mc == null )
        {
            //
            // If we still haven't had success in selecting the module, see if we can dynamically register one.
View Full Code Here

    public static void setOutputForm( ActionMapping mapping, ActionForm form,
                                      HttpServletRequest request, boolean overwrite )
    {
        if ( form != null )
        {
            ModuleConfig moduleConfig = mapping.getModuleConfig();
            Class formClass = InternalUtils.unwrapFormBean( form ).getClass();
           
            //
            // Get the names of *all* form beans of the desired type, and blast out this instance under all those names.
            //
View Full Code Here

     *         <li>the full class name, with '.' and '$' replaced by '_'.</li>
     *     </ul>
     */
    public static String getFormBeanName( Class formBeanClass, HttpServletRequest request )
    {
        ModuleConfig moduleConfig = RequestUtils.getRequestModuleConfig( request );
        List/*< String >*/ names = getFormNamesFromModuleConfig( formBeanClass.getName(), moduleConfig );
       
        if ( names != null )
        {
            assert names.size() > 0;    // getFormNamesFromModuleConfig returns null or a nonempty list
View Full Code Here

     *         <li>the full class name, with '.' and '$' replaced by '_'.</li>
     *     </ul>
     */
    private static String generateFormBeanName( Class formBeanClass, HttpServletRequest request )
    {
        ModuleConfig moduleConfig = RequestUtils.getRequestModuleConfig( request );
        String formBeanClassName = formBeanClass.getName();
       
        //
        // A form-bean wasn't found for this type, so we'll create a name.  First try and create
        // name that is a camelcased version of the classname without all of its package/outer-class
        // qualifiers.  If one with that name already exists, munge the fully-qualified classname.
        //
        String formType = formBeanClassName;
        int lastQualifier = formType.lastIndexOf( '$' );

        if ( lastQualifier == -1 )
        {
            lastQualifier = formType.lastIndexOf( '.' );
        }

        String formName = formType.substring( lastQualifier + 1 );
        formName = Character.toLowerCase( formName.charAt( 0 ) ) + formName.substring( 1 );

        if ( moduleConfig.findFormBeanConfig( formName ) != null )
        {
            formName = formType.replace( '.', '_' ).replace( '$', '_' );
            assert moduleConfig.findFormBeanConfig( formName ) == null : formName;
        }
       
        return formName;       
    }
View Full Code Here

TOP

Related Classes of org.apache.struts.config.ModuleConfig

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.