Search code examples
javasmooks

How to retrieve java objects produced by smooks


In brief: I have java.io.InputStream which contains json with a huge array of sub-elements. Following call gives me fully populated collection after processing is finished: smooks.filterSource(exCtxt, new StreamSource(inputStream), javaResult).

How can I retrieve objects on the fly, on every sub-element? (e.g. via callback)


Solution

  • If someone needs it, I did object streaming with Smooks this way:

    smooks.addVisitor(new SAXVisitAfter() {
            @Override
            public void visitAfter(SAXElement element,
                    ExecutionContext executionContext) throws SmooksException,
                    IOException {
                MyElement element = (MyElement) executionContext.getBeanContext()
                        .getBean("myElement");
                // send 'element' here;
            }
        }, "root/element");