Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
Milyn - Copyright (C) 2006 - 2010
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License (version 2.1) as published by the Free Software
Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Lesser General Public License for more details:
http://www.gnu.org/licenses/lgpl.txt
*/
package org.milyn.javabean.dynamic;
import java.io.IOException;
import java.io.Writer;
import java.util.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.milyn.assertion.AssertArgument;
import org.milyn.javabean.dynamic.serialize.BeanWriter;
import org.milyn.javabean.dynamic.serialize.DefaultNamespace;
import org.milyn.payload.JavaResult;
/**
* Model container.
*
* Contains the {@link #getModelRoot() modelRoot} object instance, as well
* as {@link #getModelMetadata() modelMetadata} associated with the
* objects wired into the object graph routed on the {@link #getModelRoot() modelRoot}.
* The {@link #getModelMetadata() modelMetadata} can contain information for, among other
* things, serializing the object graph routed at {@link #getModelRoot() modelRoot}.
*
* @author [email protected]
*/
public class Model {
private static Log logger = LogFactory.getLog(Model.class);
private T modelRoot;
private List modelMetadata;
private Map, Map> beanWriters;
private Set knownNamespaces;
private Map namespacePrefixMappings;
/**
* Public constructor.
* @param modelRoot The model root object.
* @param builder Associated model builder instance.
*/
public Model(T modelRoot, ModelBuilder builder) {
AssertArgument.isNotNull(modelRoot, "modelRoot");
AssertArgument.isNotNull(builder, "builder");
this.modelRoot = modelRoot;
this.modelMetadata = new ArrayList();
this.beanWriters = builder.getDescriptor().getBeanWriters();
this.namespacePrefixMappings = new LinkedHashMap();
resolveKnownNamespaces();
// Register the model root bean...
registerBean(modelRoot);
}
/**
* Protected constructor.
*
* Used by the {@link ModelBuilder}.
*
* @param modelRoot The model root object.
* @param modelMetadata Model metadata.
*/
protected Model(T modelRoot, List modelMetadata, Map, Map> beanWriters, Map namespacePrefixMappings) {
AssertArgument.isNotNull(modelRoot, "modelRoot");
AssertArgument.isNotNull(modelMetadata, "modelMetadata");
AssertArgument.isNotNull(beanWriters, "beanWriters");
AssertArgument.isNotNull(namespacePrefixMappings, "namespacePrefixMappings");
this.modelRoot = modelRoot;
this.modelMetadata = modelMetadata;
this.beanWriters = beanWriters;
this.namespacePrefixMappings = namespacePrefixMappings;
resolveKnownNamespaces();
}
/**
* Get the model root object instance.
* @return the model root object instance.
*/
public T getModelRoot() {
return modelRoot;
}
/**
* Resolve the set of known namespaces.
*/
private void resolveKnownNamespaces() {
// Extract the set of known namespaces based on the set of bean writers we have...
knownNamespaces = new HashSet();
Collection