Package org.apache.struts2.convention.annotation

Examples of org.apache.struts2.convention.annotation.Action


            Actions actionsAnnotation = method.getAnnotation(Actions.class);
            if (actionsAnnotation != null) {
                List<Action> actions = checkActionsAnnotation(actionsAnnotation);
                map.put(method.getName(), actions);
            } else {
                Action ann = method.getAnnotation(Action.class);
                if (ann != null) {
                    map.put(method.getName(), Arrays.asList(ann));
                }
            }
        }
View Full Code Here


    protected void buildConfiguration(Set<Class> classes) {
        Map<String, PackageConfig.Builder> packageConfigs = new HashMap<String, PackageConfig.Builder>();

        for (Class<?> actionClass : classes) {
            Actions actionsAnnotation = actionClass.getAnnotation(Actions.class);
            Action actionAnnotation = actionClass.getAnnotation(Action.class);

            // Skip classes that can't be instantiated
            if (cannotInstantiate(actionClass)) {
                if (LOG.isTraceEnabled())
                    LOG.trace("Class [#0] did not pass the instantiation test and will be ignored", actionClass.getName());
View Full Code Here

            Actions actionsAnnotation = method.getAnnotation(Actions.class);
            if (actionsAnnotation != null) {
                List<Action> actions = checkActionsAnnotation(actionsAnnotation);
                map.put(method.getName(), actions);
            } else {
                Action ann = method.getAnnotation(Action.class);
                if (ann != null) {
                    map.put(method.getName(), Arrays.asList(ann));
                }
            }
        }
View Full Code Here

    buildCfg();
    // initDispatcher(null);
  }

  protected Dispatcher initDispatcher(Map<String, String> params) {
    Dispatcher du = StrutsTestCaseHelper.initDispatcher(new MockServletContext(), params);
    configurationManager = du.getConfigurationManager();
    configuration = configurationManager.getConfiguration();
    container = configuration.getContainer();
    return du;
  }
View Full Code Here

public class GaeInitOperations extends InitOperations {

  @Override
  public Dispatcher initDispatcher(HostConfig filterConfig) {
    Dispatcher dispatcher = createDispatcher(filterConfig);
    dispatcher.init();
    return dispatcher;
  }
View Full Code Here

  public void init(FilterConfig filterConfig) throws ServletException {
    InitOperations init = new GaeInitOperations();
    try {
      FilterHostConfig config = new FilterHostConfig(filterConfig);
      init.initLogging(config);
      Dispatcher dispatcher = init.initDispatcher(config);

      init.initStaticContentLoader(config, dispatcher);

      prepare = new PrepareOperations(filterConfig.getServletContext(),
          dispatcher);
View Full Code Here

    {
        if (params == null)
        {
            params = new HashMap<String, String>();
        }
        Dispatcher dispatcher = new Dispatcher(servletContext, params);
        dispatcher.init();
        Dispatcher.setInstance(dispatcher);
        return dispatcher;
    }
View Full Code Here

            String name = (String) e.nextElement();
            String value = cfg.getInitParameter(name);
            params.put(name, value);
        }
       
        dispatcherUtils = new Dispatcher(new PortletServletContext(cfg.getPortletContext()), params);
        dispatcherUtils.init();
       
        // For testability
        if (factory == null) {
            factory = dispatcherUtils.getConfigurationManager().getConfiguration().getContainer().getInstance(ActionProxyFactory.class);
View Full Code Here

          params.put("method", action.getMethod());
        }
        return buildResult(resultCode, resultTypeConfig, context, params);
      } else if (prefix.startsWith("redirect")) {
        String targetResource = StringUtils.substringAfter(resultCode, ":");
        if (StringUtils.contains(targetResource, ':')) { return new ServletRedirectResult(
            targetResource); }
        Action action = buildAction(targetResource);
        // add special param and ajax tag for redirect
        HttpServletRequest request = ServletActionContext.getRequest();
        String redirectParamStr = request.getParameter("params");
        action.params(redirectParamStr);
        // x-requested-with->XMLHttpRequest
        if (null != request.getHeader("x-requested-with")) {
          action.param("x-requested-with", "1");
        }
        Map<String, String> params = buildResultParams(path, resultTypeConfig);
        if (null != action.getParams().get("method")) {
          params.put("method", (String) action.getParams().get("method"));
          action.getParams().remove("method");
        }
        if (StringUtils.isNotEmpty(action.getMethod())) {
          params.put("method", action.getMethod());
        }
        addNamespaceAction(action, params);

        ServletRedirectResult result = (ServletRedirectResult) buildResult(resultCode,
            resultTypeConfig, context, params);
        for (Map.Entry<String, String> param : action.getParams().entrySet()) {
          String property = param.getKey();
          result.addParameter(property, param.getValue());
        }
        return result;
      } else {
        return buildResult(resultCode, resultTypeConfig, context,
            buildResultParams(path, resultTypeConfig));
View Full Code Here

                    }
                });

                put(REDIRECT_PREFIX, new ParameterAction() {
                    public void execute(String key, ActionMapping mapping) {
                        ServletRedirectResult redirect = new ServletRedirectResult();
                        container.inject(redirect);
                        redirect.setLocation(key.substring(REDIRECT_PREFIX
                                .length()));
                        mapping.setResult(redirect);
                    }
                });

                put(REDIRECT_ACTION_PREFIX, new ParameterAction() {
                    public void execute(String key, ActionMapping mapping) {
                        String location = key.substring(REDIRECT_ACTION_PREFIX
                                .length());
                        ServletRedirectResult redirect = new ServletRedirectResult();
                        container.inject(redirect);
                        String extension = getDefaultExtension();
                        if (extension != null && extension.length() > 0) {
                            location += "." + extension;
                        }
                        redirect.setLocation(location);
                        mapping.setResult(redirect);
                    }
                });
            }
        };
View Full Code Here

TOP

Related Classes of org.apache.struts2.convention.annotation.Action

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.