public class Model<T> extends Object
modelRoot
object instance, as well
as modelMetadata
associated with the
objects wired into the object graph routed on the modelRoot
.
The modelMetadata
can contain information for, among other
things, serializing the object graph routed at modelRoot
.Modifier | Constructor and Description |
---|---|
protected |
Model(T modelRoot,
List<BeanMetadata> modelMetadata,
Map<Class<?>,Map<String,BeanWriter>> beanWriters,
Map<String,String> namespacePrefixMappings)
Protected constructor.
|
|
Model(T modelRoot,
ModelBuilder builder)
Public constructor.
|
Modifier and Type | Method and Description |
---|---|
BeanMetadata |
getBeanMetadata(Object beanInstance)
Get the model metadata.
|
BeanWriter |
getBeanWriter(Object bean)
Get the
BeanWriter instance for the specified bean, if one exists. |
List<BeanMetadata> |
getModelMetadata()
Get the model metadata.
|
T |
getModelRoot()
Get the model root object instance.
|
Map<String,String> |
getNamespacePrefixMappings()
Get the current namespace prefix mappings for this Model instance.
|
BeanMetadata |
registerBean(Object beanInstance)
Register the specified bean instance.
|
void |
writeModel(Writer writer)
Write the bean model to the specified
Writer instance. |
public Model(T modelRoot, ModelBuilder builder)
modelRoot
- The model root object.builder
- Associated model builder instance.protected Model(T modelRoot, List<BeanMetadata> modelMetadata, Map<Class<?>,Map<String,BeanWriter>> beanWriters, Map<String,String> namespacePrefixMappings)
ModelBuilder
.modelRoot
- The model root object.modelMetadata
- Model metadata.public T getModelRoot()
public BeanMetadata registerBean(Object beanInstance) throws BeanRegistrationException
@DefaultNamespace
annotation.
Note that not all beans in the model object graph need to be registered with the model. Only the
namepsace "root" beans need to be registered. The root bean of the model's object graph is often the only
namespace "root" bean in the model. This is only ever the case when the configuration is composed of a single
namespace. Many configurations are composed of multiple configuration namespaces, such as the Smooks
configurations, with the smooks-core, javabean, validation etc configuration namespaces.
In these cases, the constructed java object model for this multi-namespace configuration will have object
instance "away from" the root of the object model (down the object graph) that are associated with different
configuration namespaces. These object instances are what we call the "namespace root" beans and they need to
be registered with the model via this method. If not registered, the serialization process is likely to
fail when it attempts to locate a BeanWriter
for the bean (and it's associated configuration namespace).BeanRegistrationException
- Bean instance
already registered
, or
bean type
not annotated with the
DefaultNamespace annotation
.public List<BeanMetadata> getModelMetadata()
BeanMetadata
list containing metadata about objects
wired into the object graph, routed at the model root
.public BeanMetadata getBeanMetadata(Object beanInstance)
BeanMetadata
list containing metadata about objects
wired into the object graph, routed at the model root
.public void writeModel(Writer writer) throws BeanRegistrationException, IOException
Writer
instance.writer
- The writer instance.BeanRegistrationException
- One of the "namespace root" beans in the model is not registered
.IOException
- Error while writing the model to the supplied Writer
instance.public Map<String,String> getNamespacePrefixMappings()
public BeanWriter getBeanWriter(Object bean) throws BeanRegistrationException
BeanWriter
instance for the specified bean, if one exists.bean
- The bean.BeanWriter
instance for the specified bean, if one exists, otherwise null.BeanRegistrationException
- No BeanMetadata
for specified bean instance.Copyright © 2020. All rights reserved.