org.trails.hibernate
Class HibernateDescriptorDecorator

java.lang.Object
  extended by org.trails.hibernate.HibernateDescriptorDecorator
All Implemented Interfaces:
org.trails.descriptor.DescriptorDecorator

public class HibernateDescriptorDecorator
extends java.lang.Object
implements org.trails.descriptor.DescriptorDecorator

This decorator will add metadata information. It will replace simple reflection based TrailsPropertyIPropertyDescriptors with appropriate Hibernate descriptors

Background... TrailsDescriptorService operates one ReflectorDescriptorFactory - TrailsDescriptorService iterates/scans all class types encountered - ReflectorDescriptorFactory allocates property descriptor instance for the class type - TrailsDescriptorService decorates property descriptor by calling this module HibernateDescriptorDecorator - HibernateDescriptorDecorator caches the decorated property descriptor into a decorated descriptor list - decorated descriptor list gets populated into class descriptor for class type - TrailsDescriptorService finally populates decorated class descriptor and it's aggregated list of decorated property descriptors into it's own list/cache of referenced class descriptors

See Also:
TrailsPropertyDescriptor, ObjectReferenceDescriptor, OwningObjectReferenceDescriptor, CollectionDescriptor, EmbeddedDescriptor

Field Summary
protected static org.apache.commons.logging.Log LOG
           
 
Constructor Summary
HibernateDescriptorDecorator()
           
 
Method Summary
 org.trails.descriptor.IClassDescriptor decorate(org.trails.descriptor.IClassDescriptor descriptor)
           
 org.trails.descriptor.IPropertyDescriptor decorateAssociationDescriptor(java.lang.Class type, org.hibernate.mapping.Property mappingProperty, org.trails.descriptor.IPropertyDescriptor descriptor, org.trails.descriptor.IClassDescriptor parentClassDescriptor)
           
protected  org.trails.descriptor.IPropertyDescriptor decoratePropertyDescriptor(java.lang.Class type, org.hibernate.mapping.Property mappingProperty, org.trails.descriptor.IPropertyDescriptor descriptor, org.trails.descriptor.IClassDescriptor parentClassDescriptor)
           
protected  org.hibernate.mapping.Collection findCollectionMapping(java.lang.Class type, java.lang.String name)
           
protected  org.hibernate.metadata.ClassMetadata findMetadata(java.lang.Class type)
          Find the Hibernate metadata for this type, traversing up the hierarchy to supertypes if necessary
 java.util.List<org.trails.descriptor.IClassDescriptor> getAllDescriptors()
           
 org.trails.descriptor.IClassDescriptor getClassDescriptor(java.lang.Class type)
           
 org.trails.descriptor.DescriptorFactory getDescriptorFactory()
           
 java.lang.String getIdentifierProperty(java.lang.Class type)
           
 int getLargeColumnLength()
           
 org.springframework.orm.hibernate3.LocalSessionFactoryBean getLocalSessionFactoryBean()
           
protected  org.hibernate.mapping.PersistentClass getMapping(java.lang.Class type)
           
 org.hibernate.SessionFactory getSessionFactory()
           
 java.util.List getTypes()
           
protected  boolean notAHibernateProperty(org.hibernate.metadata.ClassMetadata classMetaData, org.trails.descriptor.IPropertyDescriptor descriptor)
           
protected  boolean notAHibernateProperty(org.hibernate.mapping.Component componentMapping, org.trails.descriptor.IPropertyDescriptor propertyDescriptor)
          Checks to see if a property descriptor is in a component mapping
 void setDescriptorFactory(org.trails.descriptor.DescriptorFactory descriptorFactory)
           
 void setLargeColumnLength(int largeColumnLength)
          Columns longer than this will have their large property set to true.
 void setLocalSessionFactoryBean(org.springframework.orm.hibernate3.LocalSessionFactoryBean localSessionFactoryBean)
           
 void setTypes(java.util.List types)
           
protected  java.util.List sortPropertyDescriptors(java.lang.Class type, java.util.List propertyDescriptors)
          The default way to order our property descriptors is by the order they appear in the hibernate config, with id first.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

protected static final org.apache.commons.logging.Log LOG
Constructor Detail

HibernateDescriptorDecorator

public HibernateDescriptorDecorator()
Method Detail

decorate

public org.trails.descriptor.IClassDescriptor decorate(org.trails.descriptor.IClassDescriptor descriptor)
Specified by:
decorate in interface org.trails.descriptor.DescriptorDecorator

decoratePropertyDescriptor

protected org.trails.descriptor.IPropertyDescriptor decoratePropertyDescriptor(java.lang.Class type,
                                                                               org.hibernate.mapping.Property mappingProperty,
                                                                               org.trails.descriptor.IPropertyDescriptor descriptor,
                                                                               org.trails.descriptor.IClassDescriptor parentClassDescriptor)

sortPropertyDescriptors

protected java.util.List sortPropertyDescriptors(java.lang.Class type,
                                                 java.util.List propertyDescriptors)
The default way to order our property descriptors is by the order they appear in the hibernate config, with id first. Any non-mapped properties are tacked on at the end, til I think of a better way.

Parameters:
propertyDescriptors -
Returns:

findMetadata

protected org.hibernate.metadata.ClassMetadata findMetadata(java.lang.Class type)
                                                     throws MetadataNotFoundException
Find the Hibernate metadata for this type, traversing up the hierarchy to supertypes if necessary

Parameters:
type -
Returns:
Throws:
MetadataNotFoundException

notAHibernateProperty

protected boolean notAHibernateProperty(org.hibernate.mapping.Component componentMapping,
                                        org.trails.descriptor.IPropertyDescriptor propertyDescriptor)
Checks to see if a property descriptor is in a component mapping

Parameters:
componentMapping -
propertyDescriptor -
Returns:
true if the propertyDescriptor property is in componentMapping

notAHibernateProperty

protected boolean notAHibernateProperty(org.hibernate.metadata.ClassMetadata classMetaData,
                                        org.trails.descriptor.IPropertyDescriptor descriptor)
Parameters:
classMetaData -
type -
Returns:

getMapping

protected org.hibernate.mapping.PersistentClass getMapping(java.lang.Class type)
Parameters:
type -
Returns:

decorateAssociationDescriptor

public org.trails.descriptor.IPropertyDescriptor decorateAssociationDescriptor(java.lang.Class type,
                                                                               org.hibernate.mapping.Property mappingProperty,
                                                                               org.trails.descriptor.IPropertyDescriptor descriptor,
                                                                               org.trails.descriptor.IClassDescriptor parentClassDescriptor)

findCollectionMapping

protected org.hibernate.mapping.Collection findCollectionMapping(java.lang.Class type,
                                                                 java.lang.String name)

getIdentifierProperty

public java.lang.String getIdentifierProperty(java.lang.Class type)

getSessionFactory

public org.hibernate.SessionFactory getSessionFactory()
Returns:
Returns the sessionFactory.

getClassDescriptor

public org.trails.descriptor.IClassDescriptor getClassDescriptor(java.lang.Class type)

getLocalSessionFactoryBean

public org.springframework.orm.hibernate3.LocalSessionFactoryBean getLocalSessionFactoryBean()
Returns:
Returns the localSessionFactoryBean.

setLocalSessionFactoryBean

public void setLocalSessionFactoryBean(org.springframework.orm.hibernate3.LocalSessionFactoryBean localSessionFactoryBean)
Parameters:
localSessionFactoryBean - The localSessionFactoryBean to set.

getAllDescriptors

public java.util.List<org.trails.descriptor.IClassDescriptor> getAllDescriptors()

getTypes

public java.util.List getTypes()

setTypes

public void setTypes(java.util.List types)

getLargeColumnLength

public int getLargeColumnLength()

setLargeColumnLength

public void setLargeColumnLength(int largeColumnLength)
Columns longer than this will have their large property set to true.

Parameters:
largeColumnLength -

getDescriptorFactory

public org.trails.descriptor.DescriptorFactory getDescriptorFactory()

setDescriptorFactory

public void setDescriptorFactory(org.trails.descriptor.DescriptorFactory descriptorFactory)


Copyright © 2004-2007. All Rights Reserved.