Package com.opensymphony.xwork2.config.entities

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


        String defaultResult = packageContext.getFullDefaultResultType();

        for (Map.Entry<String, ResultConfig> entry : results.entrySet()) {

            if (entry.getValue() == null) {
                ResultTypeConfig resultTypeConfig = packageContext.getAllResultTypeConfigs().get(defaultResult);
                entry.setValue(new ResultConfig.Builder(null, resultTypeConfig.getClassName()).build());
            }
        }
    }
View Full Code Here


        // resultValue 有两种可能:
        // 1.一种直接是字面量(比如 dispatcher:/xxx.html)
        // 2.另一种是 json 参数(比如 dispatcher:{'location': '/xxx.html'} )

        ResultTypeConfig typeConfig = resultTypes.get(resultType);
        //如果没有默认参数
        if (Strings.isNullOrEmpty(typeConfig.getDefaultResultParam())) {
            ResultConfig.Builder resultBuilder = createResultConfigFromResultType(resultCode, typeConfig);
            // 只有返回类型, 例如是 "json"
            if (resultCode.length() == resultType.length()) {
                return resultBuilder.build();
            }
            //或者 ":" 后面有 json 参数
            if (resultCode.indexOf(":") == resultType.length()) {
                String resultParam = resultCode.substring(resultType.length() + 1);
                addParamByJSON(resultBuilder, resultParam);
                return resultBuilder.build();
            }
        }
        //如果有默认参数
        else {
            //  如果是 "type:" 这种形式
            if (resultCode.indexOf(":") == resultType.length()) {
                ResultConfig.Builder resultBuilder = createResultConfigFromResultType(resultCode, typeConfig);

                // 拿到参数部分(":" 后面的部分)
                String resultParam = resultCode.substring(resultType.length() + 1);
                String location = null; // 通常是 defaultParam
                if (isJSONObject(resultParam)) { //判断是否是 json 格式
                    /**
                     * 如果是 json 形式传递 param(并非 struts json 插件)的返回结果,
                     * 如果有 location ,也需要进行路径相对路径或绝对路径转换
                     */
                    Map<String, String> params = addParamByJSON(resultBuilder, resultParam);
                    location = params.get(typeConfig.getDefaultResultParam());
                } else {
                    location = resultParam;
                }
                // 动态处理内容的路径
                location = parsePath(contentBase, routeMapping, location);
                resultBuilder.addParam(typeConfig.getDefaultResultParam(), location);
                return resultBuilder.build();
            }
        }

        return null;
View Full Code Here

    assertEquals(resultTypesConfigMap.size(), 2);
    assertTrue(resultTypesConfigMap.containsKey("result1"));
    assertTrue(resultTypesConfigMap.containsKey("result2"));
    assertFalse(resultTypesConfigMap.containsKey("result3"));
   
    ResultTypeConfig result1ResultTypeConfig = (ResultTypeConfig) resultTypesConfigMap.get("result1");
    Map result1ParamsMap = result1ResultTypeConfig.getParams();
    ResultTypeConfig result2ResultTypeConfig = (ResultTypeConfig) resultTypesConfigMap.get("result2");
    Map result2ParamsMap = result2ResultTypeConfig.getParams();
   
    assertEquals(result1ResultTypeConfig.getName(), "result1");
    assertEquals(result1ResultTypeConfig.getClazz(), MockResult.class.getName());
    assertEquals(result2ResultTypeConfig.getName(), "result2");
    assertEquals(result2ResultTypeConfig.getClazz(), MockResult.class.getName());
    assertEquals(result1ParamsMap.size(), 3);
    assertEquals(result2ParamsMap.size(), 2);
    assertTrue(result1ParamsMap.containsKey("param1"));
    assertTrue(result1ParamsMap.containsKey("param2"));
    assertTrue(result1ParamsMap.containsKey("param3"));
View Full Code Here

    ProfileService profileService = new ProfileServiceImpl();
    actionNameBuilder.setProfileService(profileService);

    ObjectFactory of = new ObjectFactory();
    final DummyContainer mockContainer = new DummyContainer();
    Configuration configuration = new DefaultConfiguration() {
      @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());
View Full Code Here

    public <T> T getInstance(Class<T> type) {
      try {
        T obj = type.newInstance();
        if (obj instanceof ObjectFactory) {
          ((ObjectFactory) obj).setReflectionProvider(new OgnlReflectionProvider() {

            @Override
            public void setProperties(Map<String, String> properties, Object o) {
            }
View Full Code Here

    this.configuration = configuration;
    this.objectFactory = objectFactory;
    this.defaultParentPackage = "beangle";
    if (objectFactory instanceof SpringObjectFactory) {
      beanNameFinder = new SpringBeanNameFinder();
      SpringObjectFactory sf = (SpringObjectFactory) objectFactory;
      sf.autoWireBean(beanNameFinder);
    }
  }
View Full Code Here

      sf.autoWireBean(beanNameFinder);
    }
  }

  protected void initReloadClassLoader() {
    if (isReloadEnabled() && reloadingClassLoader == null) reloadingClassLoader = new ReloadingClassLoader(
        getClassLoader());
  }
View Full Code Here

        @Override
        public boolean contains(Object o) {
          return !ObjectUtils.equals(o, "file");
        }
      };
      ClassFinder finder = new ClassFinder(getClassLoaderInterface(), buildUrls(), false, jarProtocols);
      for (String packageName : actionPackages) {
        Test<ClassFinder.ClassInfo> test = getPackageFinderTest(packageName);
        classes.addAll(finder.findClasses(test));
      }
    } catch (Exception ex) {
      logger.error("Unable to scan named packages", ex);
    }
    return classes;
View Full Code Here

  }

  protected ClassLoaderInterface getClassLoaderInterface() {
    if (isReloadEnabled()) return new ClassLoaderInterfaceDelegate(reloadingClassLoader);
    else {
      ClassLoaderInterface classLoaderInterface = null;
      ActionContext ctx = ActionContext.getContext();
      if (ctx != null) classLoaderInterface = (ClassLoaderInterface) ctx
          .get(ClassLoaderInterface.CLASS_LOADER_INTERFACE);
      return (ClassLoaderInterface) ObjectUtils.defaultIfNull(classLoaderInterface,
          new ClassLoaderInterfaceDelegate(getClassLoader()));
View Full Code Here

  }

  private Set<URL> buildUrls() {
    Set<URL> urls = CollectUtils.newHashSet();
    Enumeration<URL> em;
    ClassLoaderInterface classloader = getClassLoaderInterface();
    try {
      em = classloader.getResources("struts-plugin.xml");
      while (em.hasMoreElements()) {
        URL url = em.nextElement();
        urls.add(new URL(substringBeforeLast(url.toExternalForm(), "struts-plugin.xml")));
      }
      em = classloader.getResources("struts.xml");
      while (em.hasMoreElements()) {
        URL url = em.nextElement();
        urls.add(new URL(substringBeforeLast(url.toExternalForm(), "struts.xml")));
      }
    } catch (IOException e) {
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.