[jbosstools-issues] [JBoss JIRA] Created: (JBIDE-5307) Generalize the model creation code

Tom Fennelly (JIRA) jira-events at lists.jboss.org
Mon Nov 30 08:01:30 EST 2009


Generalize the model creation code
----------------------------------

                 Key: JBIDE-5307
                 URL: https://jira.jboss.org/jira/browse/JBIDE-5307
             Project: Tools (JBoss Tools)
          Issue Type: Task
          Components: smooks
            Reporter: Tom Fennelly
             Fix For: 3.1.0.GA


At the moment, we are using the Smooks programmatic APIs to configure the input parser etc for creating the input model.  This requires translation of the EMF config model into java code instructions for configuring the Smooks Reader - see JsonInputDataParser, CSVDataParser, EDIDataParser.

I think this can be simplified significantly by simply asking Smooks to process the Smooks config and then extracting the reader configuration from the Smooks instance and reuse that to configure an empty Smooks config... and then parse the input to extract the model.

The code would be something like this...

// Get the Reader config from the Smooks config file....
Smooks smooks1 = new Smooks(smooksConfigStream);
ExecutionContext execCtx = smooks1.createExecutionContext();
SmooksResourceConfiguration readerConfig = AbstractParser.getSAXParserConfiguration(execCtx.getDeliveryConfig());

// Create a second "empty" Smooks instance and add the reader config to it....
Smooks smooks2 = new Smooks();
smooks.addConfiguration(readerConfig);

// Filter the input message through this second Smooks instance and capture the model in the DOMResult...
DOMResult result = new DOMResult();
smooks2.filterSource(new StreamSource(inputMessageStream), result);

// And get the model DOM instance (org.w3c.dom.Document)... 
Document inputModelDOM = (Document) result.getNode();


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the jbosstools-issues mailing list