net.sf.xsnapshot.spring
Class XSnapshotRegistryFactoryBean

java.lang.Object
  extended bynet.sf.xsnapshot.spring.XSnapshotRegistryFactoryBean
All Implemented Interfaces:
org.springframework.beans.factory.FactoryBean, org.springframework.beans.factory.InitializingBean

public class XSnapshotRegistryFactoryBean
extends Object
implements org.springframework.beans.factory.FactoryBean, org.springframework.beans.factory.InitializingBean

A Spring Factory Bean that creates a XSnapshotRegistry based on its configured settings. This is the preferred way to configure a XSnapshotRegistry as the programmer can then take advantage of Spring's IoC container to configure any custom transformers and snapshot helpers, as well as to inject the registry to any of the beans that depend on it.

Parent Registries may be specified via the parentRegistries property. They are applied in the order they appear in the list - thus later registries' mappings will override earlier ones.

A number of xsnapshot properties files can be specified using the "configLocations" property, using Spring's Resource abstraction. These will be applied after the parent registries have been configured, and in the order they appear in the list.

individual custom transformers and snapshot helpers can be specified through the transformerMappings and helperMappings properties. These are applied last and therefore would override any previously defined transformers/helpers.

Author:
Daniel Kokotov

Constructor Summary
XSnapshotRegistryFactoryBean()
           
 
Method Summary
 void afterPropertiesSet()
           
 Object getObject()
           
 Class getObjectType()
           
 boolean isSingleton()
           
 void setConfigLocations(org.springframework.core.io.Resource[] configLocations)
          Specifies list of xsnapshot properties resources from which to read in snapshot, helper and transformer mappings.
 void setHelperMappings(Map helperMappings)
          Specifies custom helper mappings to add to the registry as a map of Class->net.sf.xsnapshot.SnapshotHelper.
 void setParentRegistries(XSnapshotRegistry[] parentRegistries)
          Specifies a list of xsnapshot registries from which this registry should inherit snapshot, helper and transformer mappings.
 void setTransformerMappings(Map transformerMappings)
          Specifies transformer mappings to add to the registry as a map of String->net.sf.xsnapshot.Transformer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XSnapshotRegistryFactoryBean

public XSnapshotRegistryFactoryBean()
Method Detail

afterPropertiesSet

public void afterPropertiesSet()
                        throws XSnapshotConfigurationException,
                               IOException,
                               org.apache.commons.configuration.ConfigurationException
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
XSnapshotConfigurationException
IOException
org.apache.commons.configuration.ConfigurationException

getObject

public Object getObject()
Specified by:
getObject in interface org.springframework.beans.factory.FactoryBean

getObjectType

public Class getObjectType()
Specified by:
getObjectType in interface org.springframework.beans.factory.FactoryBean

isSingleton

public boolean isSingleton()
Specified by:
isSingleton in interface org.springframework.beans.factory.FactoryBean

setTransformerMappings

public void setTransformerMappings(Map transformerMappings)
Specifies transformer mappings to add to the registry as a map of String->net.sf.xsnapshot.Transformer. The keys of the map should be transformer names used in the xdoclet markup, and the values should be the Transformer instances that implement those transformations.

Parameters:
transformerMappings - The transformerMappings to set.

setHelperMappings

public void setHelperMappings(Map helperMappings)
Specifies custom helper mappings to add to the registry as a map of Class->net.sf.xsnapshot.SnapshotHelper. The keys of the map should be the snapshot Classes, and the values should be the SnapshotHelper instances that will be used to convert models to those snapshots, and back. The typical usage would be to subclass the generated helper class, override and implement any custom logic, configure an instance of the subclass in spring with any needed dependencies, and then include in this map.

Parameters:
helperMappings - The helperMappings to set.

setConfigLocations

public void setConfigLocations(org.springframework.core.io.Resource[] configLocations)
Specifies list of xsnapshot properties resources from which to read in snapshot, helper and transformer mappings. These should be in the format described in the Javadoc for XSnapshotPropertiesConfigurator.

Parameters:
configLocations - The configLocations to set.

setParentRegistries

public void setParentRegistries(XSnapshotRegistry[] parentRegistries)
Specifies a list of xsnapshot registries from which this registry should inherit snapshot, helper and transformer mappings. Set the parentRegistries.

Parameters:
parentRegistries - The parentRegistries to set