public class ModelBuilder extends Object
Useful for constructing configuration model etc. Allows you to build a config model for a dynamic configuration namespace i.e. a config namespace that is evolving and being extended all the time. New namespaces can be easily added or extended. All that's required is to define the new config XSD and the Smooks Java Binding config to bind the data in the config namespace into the target Java model.
The namespaces all need to be configured in a "descriptor" .properties file located on the classpath. Here's an example:
mycomp.namespace=http://www.acme.com/xsd/mycomp.xsd mycomp.schemaLocation=/META-INF/xsd/mycomp.xsd mycomp.bindingConfigLocation=/META-INF/xsd/mycomp-binding.xmlYou should use a unique descriptor path for a given configuration model. Of course there can be many instances of this file on the classpath i.e. one per module/jar. This allows you to easily add extensions and updates to your configuration model, without having to define new Java model for the new namespaces (versions) etc.
Constructor and Description |
---|
ModelBuilder(Descriptor descriptor,
boolean validate) |
ModelBuilder(String descriptorPath,
boolean validate) |
Modifier and Type | Method and Description |
---|---|
protected Descriptor |
getDescriptor() |
boolean |
isValidating() |
<T> Model<T> |
readModel(InputStream message,
Class<T> modelRoot) |
<T> Model<T> |
readModel(Reader message,
Class<T> modelRoot) |
<T> T |
readObject(InputStream message,
Class<T> returnType) |
<T> T |
readObject(Reader message,
Class<T> returnType) |
void |
setReportPath(String reportPath) |
public ModelBuilder(Descriptor descriptor, boolean validate) throws SAXException, IOException
SAXException
IOException
public ModelBuilder(String descriptorPath, boolean validate) throws SAXException, IOException
SAXException
IOException
public boolean isValidating()
protected Descriptor getDescriptor()
public void setReportPath(String reportPath)
public <T> T readObject(InputStream message, Class<T> returnType) throws SAXException, IOException
SAXException
IOException
public <T> T readObject(Reader message, Class<T> returnType) throws SAXException, IOException
SAXException
IOException
public <T> Model<T> readModel(InputStream message, Class<T> modelRoot) throws SAXException, IOException
SAXException
IOException
public <T> Model<T> readModel(Reader message, Class<T> modelRoot) throws SAXException, IOException
SAXException
IOException
Copyright © 2020. All rights reserved.