Package com.opensymphony.xwork2.config.entities

Examples of com.opensymphony.xwork2.config.entities.ResultTypeConfig


    }
    Set<String> namespaces = byNamespace.keySet();
    for (String namespace : namespaces) {
      // First see if the namespace has an index action
      PackageConfig.Builder pkgConfig = byNamespace.get(namespace);
      ActionConfig indexActionConfig = pkgConfig.build().getAllActionConfigs().get("index");
      if (indexActionConfig == null) {
        continue;
      }
      if (pkgConfig.build().getAllActionConfigs().get("") == null) {
        logger.debug("Creating index ActionConfig with an action name of [] for the action class {}",
            indexActionConfig.getClassName());
        pkgConfig.addActionConfig("", indexActionConfig);
        createCount++;
      }
    }
    return createCount;
View Full Code Here


      @Override
      public Container getContainer() {
        return mockContainer;
      }
    };
    PackageConfig strutsDefault = makePackageConfig("beangle", null, null, "dispatcher", null, null, null);
    configuration.addPackageConfig("beangle", strutsDefault);
    // ResultMapBuilder resultMapBuilder =
    // createStrictMock(ResultMapBuilder.class);
    // set beans on mock container
    mockContainer.setActionNameBuilder(actionNameBuilder);
    // mockContainer.setResultMapBuilder(resultMapBuilder);
    // mockContainer.setConventionsService(new ConventionsServiceImpl(""));

    SmartActionConfigBuilder builder = new SmartActionConfigBuilder(configuration, mockContainer, of);
    builder.setActionBuilder(actionNameBuilder);
    builder.buildActionConfigs();
    Set<String> names = configuration.getPackageConfigNames();
    for (String a : names) {
      System.out.println("pkgname:" + a);
      PackageConfig pkgConfig = configuration.getPackageConfig(a);
      System.out.println("namespace:" + pkgConfig.getNamespace());
      Map<String, ActionConfig> configs = pkgConfig.getAllActionConfigs();
      for (String actionName : configs.keySet()) {
        ActionConfig config = configs.get(actionName);
        System.out.println(config.getClassName());
        System.out.println(config.getName());
        System.out.println(config.getMethodName());
View Full Code Here

      super(packageConfig);
    }

    public boolean equals(Object obj) {
      if (!(obj instanceof PackageConfig)) return false;
      PackageConfig other = (PackageConfig) obj;
      return getName().equals(other.getName()) && getNamespace().equals(other.getNamespace())
          && getParents().get(0) == other.getParents().get(0)
          && getParents().size() == other.getParents().size();
    }
View Full Code Here

    ActionConfig.Builder actionConfig = new ActionConfig.Builder(pkgCfg.getName(), action.getName(),
        beanName);
    actionConfig.methodName(action.getMethod());
    String actionName = action.getName();
    // check action exists on that package (from XML config probably)
    PackageConfig existingPkg = configuration.getPackageConfig(pkgCfg.getName());
    boolean create = true;
    if (existingPkg != null) {
      ActionConfig existed = existingPkg.getActionConfigs().get(actionName);
      create = (null == existed);
    }
    if (create) {
      pkgCfg.addActionConfig(actionName, actionConfig.build());
      logger.debug("Add {}/{} for {} in {}", new Object[] { pkgCfg.getNamespace(), actionName,
View Full Code Here

  protected PackageConfig.Builder getPackageConfig(Profile profile,
      final Map<String, PackageConfig.Builder> packageConfigs, Action action, final Class<?> actionClass) {
    // 循环查找父包
    String actionPkg = actionClass.getPackage().getName();
    PackageConfig parentPkg = null;
    while (StringUtils.contains(actionPkg, '.')) {
      parentPkg = configuration.getPackageConfig(actionPkg);
      if (null != parentPkg) {
        break;
      } else {
        actionPkg = StringUtils.substringBeforeLast(actionPkg, ".");
      }
    }
    if (null == parentPkg) {
      actionPkg = defaultParentPackage;
      parentPkg = configuration.getPackageConfig(actionPkg);
    }
    if (parentPkg == null) { throw new ConfigurationException("Unable to locate parent package ["
        + actionClass.getPackage().getName() + "]"); }
    String actionPackage = actionClass.getPackage().getName();
    PackageConfig.Builder pkgConfig = packageConfigs.get(actionPackage);
    if (pkgConfig == null) {
      PackageConfig myPkg = configuration.getPackageConfig(actionPackage);
      if (null != myPkg) {
        pkgConfig = new PackageConfig.Builder(myPkg);
      } else {
        pkgConfig = new PackageConfig.Builder(actionPackage).namespace(action.getNamespace())
            .addParent(parentPkg);
View Full Code Here

  @Inject
  protected ActionBuilder actionNameBuilder;

  public Result build(String resultCode, ActionConfig actionConfig, ActionContext context) {
    String path = null;
    ResultTypeConfig resultTypeConfig = null;

    logger.debug("result code:{} for actionConfig:{}", resultCode, actionConfig);
    if (null == resultTypeConfigs) {
      PackageConfig pc = configuration.getPackageConfig(actionConfig.getPackageName());
      this.resultTypeConfigs = pc.getAllResultTypeConfigs();
View Full Code Here

        ServletContext context = mockServletContext("/WEB-INF/location");
        this.conventionsService = new ConventionsServiceImpl("/WEB-INF/location");
        DefaultResultMapBuilder builder = new DefaultResultMapBuilder(context, container, "dispatcher,velocity,freemarker");

        ResultTypeConfig resultType = new ResultTypeConfig.Builder("dispatcher", ServletDispatcherResult.class.getName()).
                addParam("key", "value").addParam("key1", "value1").defaultResultParam("location").build();
        ResultConfig globalError = new ResultConfig.Builder("error", ServletDispatcherResult.class.getName()).
                addParam("location", "/globalError.jsp").
                build();
        PackageConfig packageConfig = new PackageConfig.Builder("package").
View Full Code Here

        EasyMock.replay(context);

        this.conventionsService = new ConventionsServiceImpl("/WEB-INF/location");
        DefaultResultMapBuilder builder = new DefaultResultMapBuilder(context, container, "dispatcher,velocity,freemarker");

        ResultTypeConfig resultType = new ResultTypeConfig.Builder("dispatcher", ServletDispatcherResult.class.getName()).
                addParam("key", "value").addParam("key1", "value1").defaultResultParam("location").build();
        ResultConfig globalError = new ResultConfig.Builder("error", ServletDispatcherResult.class.getName()).
                addParam("location", "/globalError.jsp").
                build();
        PackageConfig packageConfig = new PackageConfig.Builder("package").
View Full Code Here

    }

    public void testClassPath() throws Exception {
        ServletContext context = EasyMock.createNiceMock(ServletContext.class);

        ResultTypeConfig resultType = new ResultTypeConfig.Builder("freemarker", "org.apache.struts2.dispatcher.ServletDispatcherResult").
                defaultResultParam("location").build();
        PackageConfig packageConfig = new PackageConfig.Builder("package").
                defaultResultType("dispatcher").addResultTypeConfig(resultType).build();

        this.conventionsService = new ConventionsServiceImpl("/WEB-INF/component");
View Full Code Here

        assertEquals(1, results.get("foo").getParams().size());
        assertEquals("/WEB-INF/component/no-annotation-foo.ftl", results.get("foo").getParams().get("location"));
    }

    private PackageConfig createPackageConfigBuilder(String namespace) {
        ResultTypeConfig resultType = new ResultTypeConfig.Builder("dispatcher", "org.apache.struts2.dispatcher.ServletDispatcherResult").
                addParam("key", "value").addParam("key1", "value1").defaultResultParam("location").build();

        ResultTypeConfig redirect = new ResultTypeConfig.Builder("redirectAction",
                "org.apache.struts2.dispatcher.ServletActionRedirectResult").defaultResultParam("actionName").build();

        ResultTypeConfig ftlResultType = new ResultTypeConfig.Builder("freemarker",
                "org.apache.struts2.views.freemarker.FreemarkerResult").defaultResultParam("location").build();

        return new PackageConfig.Builder("package").
                namespace(namespace).
                defaultResultType("dispatcher").
View Full Code Here

TOP

Related Classes of com.opensymphony.xwork2.config.entities.ResultTypeConfig

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.