org.milyn.javabean.dynamic
Class ModelBuilder

java.lang.Object
  extended by org.milyn.javabean.dynamic.ModelBuilder

public class ModelBuilder
extends Object

Dynamic Model Builder.

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.xml
 
You 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.

Author:
tom.fennelly@gmail.com

Constructor Summary
ModelBuilder(Descriptor descriptor, boolean validate)
           
ModelBuilder(String descriptorPath, boolean validate)
           
 
Method Summary
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)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModelBuilder

public ModelBuilder(Descriptor descriptor,
                    boolean validate)
             throws SAXException,
                    IOException
Throws:
SAXException
IOException

ModelBuilder

public ModelBuilder(String descriptorPath,
                    boolean validate)
             throws SAXException,
                    IOException
Throws:
SAXException
IOException
Method Detail

isValidating

public boolean isValidating()

getDescriptor

protected Descriptor getDescriptor()

setReportPath

public void setReportPath(String reportPath)

readObject

public <T> T readObject(InputStream message,
                        Class<T> returnType)
             throws SAXException,
                    IOException
Throws:
SAXException
IOException

readObject

public <T> T readObject(Reader message,
                        Class<T> returnType)
             throws SAXException,
                    IOException
Throws:
SAXException
IOException

readModel

public <T> Model<T> readModel(InputStream message,
                              Class<T> modelRoot)
                   throws SAXException,
                          IOException
Throws:
SAXException
IOException

readModel

public <T> Model<T> readModel(Reader message,
                              Class<T> modelRoot)
                   throws SAXException,
                          IOException
Throws:
SAXException
IOException


Copyright © 2018. All rights reserved.