net.xoetrope.optional.data.pojo
Class XPojoDataSource

java.lang.Object
  extended by net.xoetrope.data.XDataSource
      extended by net.xoetrope.optional.data.pojo.XPojoDataSource
Direct Known Subclasses:
XPojoHibernateDataSource

public class XPojoDataSource
extends XDataSource

A data source for working with POJOs. When the application is loaded the datasources are instantiated and in the case of a XPojoDataSource the XPojoRoot instance specified by the root element is instantiated and configured. The configuration project involves traversing the class hierarchy and setting up XPojoModel nodes or proxies for each class in the pojo hierarchy. The configuration can specify naming overrides if the names established by reflection are not suitable

Copyright (c) Xoetrope Ltd., 2001-2006
License: see license.txt


Field Summary
protected  java.util.Hashtable adapters
           
protected  java.util.Hashtable overrides
           
protected  XPojoContext pojoContext
           
protected  XModel pojoRootModel
           
 
Fields inherited from class net.xoetrope.data.XDataSource
currentProject
 
Constructor Summary
XPojoDataSource(XProject project)
          Creates a new instance of XPojoDataSource
 
Method Summary
protected  XPojoAdapter createAdapter(java.lang.Class pojoClass)
          Creates and returns a XPojoAdpater
protected  XPojoModel createPojoModel(XModel parent, java.lang.Object pojo)
          Creates and returns a new instance of XPojoModel
protected  XPojoModel createPojoModel(XModel parent, java.lang.String subPath)
          Creates and returns a new instance of XPojoModel
protected  void customizeProperty(XPojoAdapter adapter, XmlElement propertyElement)
           
 XPojoAdapter getAdapter(java.lang.Object pojo)
          Gets the adapter for the specified POJO
 XPojoContext getPojoContext()
          Returns the pojo context object
protected  XPojoContext instantiatePojoContext(java.lang.String className, java.lang.ClassLoader classLoader)
          Creates and returns new XPojoContext object
 void loadTable(XmlElement source, XModel model)
          Recursively load the model data
protected  void overrideAdapter(XPojoAdapter adapter)
          Override the adapter specification loaded via reflection and add the customization specified by the configuration
 
Methods inherited from class net.xoetrope.data.XDataSource
outputModel, outputModel, outputModel, read, read, readDataSource, setUseValueAsId, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pojoContext

protected XPojoContext pojoContext

pojoRootModel

protected XModel pojoRootModel

overrides

protected java.util.Hashtable overrides

adapters

protected java.util.Hashtable adapters
Constructor Detail

XPojoDataSource

public XPojoDataSource(XProject project)
Creates a new instance of XPojoDataSource

Parameters:
project - the owner project
Method Detail

getPojoContext

public XPojoContext getPojoContext()
Returns the pojo context object

Returns:
pojo context

instantiatePojoContext

protected XPojoContext instantiatePojoContext(java.lang.String className,
                                              java.lang.ClassLoader classLoader)
                                       throws java.lang.Exception
Creates and returns new XPojoContext object

Parameters:
className - the name of the class, the instance of which should be returned
classLoader - class loader object to load the specified class definition
Returns:
XPojoContext object
Throws:
java.lang.Exception

loadTable

public void loadTable(XmlElement source,
                      XModel model)
Recursively load the model data

Overrides:
loadTable in class XDataSource
Parameters:
source - the source element
model - the model for the source element

getAdapter

public XPojoAdapter getAdapter(java.lang.Object pojo)
Gets the adapter for the specified POJO

Parameters:
pojo - the object for which the adapter is to be returned
Returns:
the pojo adapter

createAdapter

protected XPojoAdapter createAdapter(java.lang.Class pojoClass)
Creates and returns a XPojoAdpater

Parameters:
pojoClass - pojoClass class to be adapted by the returned adapter
Returns:
XPojoAdapter object

createPojoModel

protected XPojoModel createPojoModel(XModel parent,
                                     java.lang.String subPath)
Creates and returns a new instance of XPojoModel

Parameters:
parent - the parent model of the model node which is to be created
subpath - String consisting of pojo properties, must be in the format: propertyName(arguments...)[idx]
Returns:
XPojoModel object

createPojoModel

protected XPojoModel createPojoModel(XModel parent,
                                     java.lang.Object pojo)
Creates and returns a new instance of XPojoModel

Parameters:
parent - the parent model node
Returns:
XPojoModel object

overrideAdapter

protected void overrideAdapter(XPojoAdapter adapter)
Override the adapter specification loaded via reflection and add the customization specified by the configuration

Parameters:
adapter - the adapter being customized

customizeProperty

protected void customizeProperty(XPojoAdapter adapter,
                                 XmlElement propertyElement)