0

需要任何人的建议。

if you look at the below code,every time I am creating the new object for smooks as ftlname dynamically get populated.
        try {
              Smooks smooks1 = new Smooks("smooks-config.xml");
            if (ftlName != null) {
                inputStream = new ByteArrayInputStream(xmlMessage.toString()
                        .getBytes());
                outStream = new ByteArrayOutputStream();
                smooks1.addVisitor(new FreeMarkerTemplateProcessor(
                        new TemplatingConfiguration(ftlName)));
                smooks1.filterSource(new StreamSource(inputStream),
                        new StreamResult(outStream));
                resultString = outStream.toString();
                inputStream.close();
                outStream.close();
            }
        } catch (Exception ee) { }

每次创建 smooks 对象时,当我尝试使用单个 smooks 实例时,这确实达到了性能,低于错误。

java.lang.UnsupportedOperationException: Unsupported call to Smooks instance configuration method after Smooks instance has created an ExecutionContext.
     at org.milyn.Smooks.assertIsConfigurable(Smooks.java:588) [milyn-smooks-all-1.5.1.jar:]
     at org.milyn.Smooks.addVisitor(Smooks.java:262) [milyn-smooks-all-1.5.1.jar:]
     at org.milyn.Smooks.addVisitor(Smooks.java:241) [milyn-smooks-all-1.5.1.jar:]

can you please provide your advice on it.
smooks version :- 1.5.1
4

1 回答 1

0

我的猜测(未验证)是您无法使用 XML 文件(在构造函数中)配置 Smooks 实例,然后继续通过 addVisitor() 添加更多访问者实现。

您没有在 smooks 配置中配置 freemarker 模板是否有原因?

于 2013-11-12T11:46:20.943 回答