Package org.apache.struts.config

Examples of org.apache.struts.config.ModuleConfig


  }
 
  protected ModuleSelector extend(final ModuleSelector delegate) {
    return new ModuleSelector() {
      public ModuleContext getModuleContext(HttpServletRequest request) {
        ModuleConfig config = ModuleUtils.getInstance().getModuleConfig(request);
        if (config != null) {
          ModuleContext module = getStrutsModuleContext(config);
          if (module != null) {
            return module;
          }
View Full Code Here


     * @param context session
     * @param key bundle key
     * @return resources
     */
    public static MessageResources getMessageResources(ServletContext context, String key) {
        ModuleConfig moduleConfig = ModuleUtils.getInstance().getModuleConfig("", context);
        return (MessageResources) context.getAttribute(key + moduleConfig.getPrefix());
    }
View Full Code Here

            initServlet();

            getServletContext().setAttribute(Globals.ACTION_SERVLET_KEY, this);
            initModuleConfigFactory();
            // Initialize modules as needed
            ModuleConfig moduleConfig = initModuleConfig("", config);
            initCore();

            // Start extensions
            bootProgressMonitor.updateMessage("Starting extensions");
            bootProgressMonitor.updateProgress(30);
View Full Code Here

            List<Pair> listItemsList = new ArrayList<Pair>();
            if (!definition.getTypeMeta().startsWith("!")) {
                for (Iterator i = ((List) definition.getTypeMetaObject()).iterator(); i.hasNext();) {
                    TypeMetaListItem item = (TypeMetaListItem) i.next();
                    ServletContext context = CoreServlet.getServlet().getServletContext();
                    ModuleConfig moduleConfig = ModuleUtils.getInstance().getModuleConfig(request, context);
                    String mrKey = (item.getMessageResourcesKey() == null ? "properties" : item.getMessageResourcesKey())
                                    + moduleConfig.getPrefix();
                    MessageResources res = (MessageResources) context.getAttribute(mrKey);
                    String k = definition.getName() + ".value." + item.getValue();
                    String v = "";
                    if (res != null) {
                        v = res.getMessage((Locale) request.getSession().getAttribute(Globals.LOCALE_KEY), k);
View Full Code Here

    // or the module attribute is already in use.
    String bundle = I18nSupport.getInstance(context).resolveBundle("calyxo-forms-validators");
    if (context.getAttribute(bundle) == null) {  // do not overwrite attribute in use
      MessageResourcesConfig messages = moduleConfig.findMessageResourcesConfig(bundle);
      if (messages == null) { // messages might be declared in the default module
        ModuleConfig defaultConfig = ModuleUtils.getInstance().getModuleConfig("", servlet.getServletContext());
        if (moduleConfig != defaultConfig && defaultConfig != null) {
          messages = defaultConfig.findMessageResourcesConfig(bundle);
        }
        if (messages == null) {  // no messages declared --> install message resources
          MessageResourcesFactory.setFactoryClass(PropertyMessageResourcesFactory.class.getName());
          MessageResources resources = MessageResourcesFactory.createFactory().createResources(bundle);
          context.setAttribute(bundle, resources);
View Full Code Here

            List<Pair> listItemsList = new ArrayList<Pair>();
            if (!definition.getTypeMeta().startsWith("!")) {
                for (Iterator i = ((List) definition.getTypeMetaObject()).iterator(); i.hasNext();) {
                    TypeMetaListItem item = (TypeMetaListItem) i.next();
                    ServletContext context = CoreServlet.getServlet().getServletContext();
                    ModuleConfig moduleConfig = ModuleUtils.getInstance().getModuleConfig(request, context);
                    String mrKey = (item.getMessageResourcesKey() == null ? "properties" : item.getMessageResourcesKey())
                                    + moduleConfig.getPrefix();
                    MessageResources res = (MessageResources) context.getAttribute(mrKey);
                    String k = definition.getName() + ".value." + item.getValue();
                    String v = "";
                    if (res != null) {
                        v = res.getMessage((Locale) request.getSession().getAttribute(Globals.LOCALE_KEY), k);
View Full Code Here

     */
    protected TilesRequestProcessor getRequestProcessor(
        HttpServletRequest request,
        ServletContext servletContext) {

        ModuleConfig moduleConfig = getModuleConfig(request, servletContext);

        return (TilesRequestProcessor) servletContext.getAttribute(
            Globals.REQUEST_PROCESSOR_KEY + moduleConfig.getPrefix());
    }
View Full Code Here

     */
    protected ModuleConfig getModuleConfig(
        HttpServletRequest request,
        ServletContext servletContext) {

        ModuleConfig moduleConfig =
            ModuleUtils.getInstance().getModuleConfig(request);

        if (moduleConfig == null) {
            // ModuleConfig not found in current request. Select it.
            ModuleUtils.getInstance().selectModule(request, servletContext);
View Full Code Here

    else {
      MessageResources resources = (MessageResources) pageContext.getAttribute(Globals.MESSAGES_KEY,
          PageContext.REQUEST_SCOPE);

      if (resources == null) {
        ModuleConfig moduleConfig = (ModuleConfig) pageContext.getRequest().getAttribute(Globals.MODULE_KEY);

        if (moduleConfig == null) {
          moduleConfig = (ModuleConfig) pageContext.getServletContext().getAttribute(Globals.MODULE_KEY);
          pageContext.getRequest().setAttribute(Globals.MODULE_KEY, moduleConfig);
        }

        resources = (MessageResources) pageContext.getAttribute(
            Globals.MESSAGES_KEY + moduleConfig.getPrefix(), PageContext.APPLICATION_SCOPE);
      }

      if (resources == null) {
        resources = (MessageResources) pageContext.getAttribute(Globals.MESSAGES_KEY,
            PageContext.APPLICATION_SCOPE);
View Full Code Here

    private static SecureActionConfig getActionConfig(HttpServletRequest
            request,
            ServletContext app,
            String linkString)
    {
        ModuleConfig moduleConfig = StrutsUtils.selectModule(linkString, app);

        // Strip off the module path, if any
        linkString = linkString.substring(moduleConfig.getPrefix().length());

        // Use our servlet mapping, if one is specified
        //String servletMapping = (String)app.getAttribute(Globals.SERVLET_KEY);

        SecurePlugInInterface spi = (SecurePlugInInterface)app.getAttribute(
                SecurePlugInInterface.SECURE_PLUGIN);
        Iterator mappingItr = spi.getServletMappings().iterator();
        while (mappingItr.hasNext())
        {
            String servletMapping = (String)mappingItr.next();

            int starIndex = servletMapping != null ? servletMapping.indexOf('*')
                            : -1;
            if (starIndex == -1)
            {
                continue;
            } // No servlet mapping or no usable pattern defined, short circuit

            String prefix = servletMapping.substring(0, starIndex);
            String suffix = servletMapping.substring(starIndex + 1);

            // Strip off the jsessionid, if any
            int jsession = linkString.indexOf(";jsessionid=");
            if (jsession >= 0)
            {
                linkString = linkString.substring(0, jsession);
            }

            // Strip off the query string, if any
            // (differs from the SSL Ext. version - query string before anchor)
            int question = linkString.indexOf("?");
            if (question >= 0)
            {
                linkString = linkString.substring(0, question);
            }

            // Strip off the anchor, if any
            int anchor = linkString.indexOf("#");
            if (anchor >= 0)
            {
                linkString = linkString.substring(0, anchor);
            }


            // Unable to establish this link as an action, short circuit
            if (!(linkString.startsWith(prefix) && linkString.endsWith(suffix)))
            {
                continue;
            }

            // Chop off prefix and suffix
            linkString = linkString.substring(prefix.length());
            linkString = linkString.substring(0,
                                              linkString.length()
                                              - suffix.length());
            if (!linkString.startsWith("/"))
            {
                linkString = "/" + linkString;
            }

            SecureActionConfig secureConfig = (SecureActionConfig)moduleConfig.
                                              findActionConfig(linkString);

            return secureConfig;
        }
        return null;
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.