org.compass.spring
Class CompassDaoSupport

java.lang.Object
  extended by org.compass.spring.CompassDaoSupport
All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean

public abstract class CompassDaoSupport
extends Object
implements org.springframework.beans.factory.InitializingBean

Convenient super class for Compass data access objects.

Requires either a Compass or a CompassTemplate to be set.

The base class is intended for CompassTemplate usage, and it creates a new CompassTemplate if a Compass parameter is set.

Author:
kimchy

Field Summary
protected  org.apache.commons.logging.Log log
           
 
Constructor Summary
CompassDaoSupport()
           
 
Method Summary
 void afterPropertiesSet()
           
protected  CompassTemplate createCompassTemplate(Compass compass)
          Creates a new CompassTemplate based on the provided Compass.
 Compass getCompass()
          Returns the Compass used by the DAO.
 CompassTemplate getCompassTemplate()
          Returns the CompassTemplate for this DAO.
protected  void initDao()
           
 void setCompass(Compass compass)
          Sets the Compass to be used by this DAO.
 void setCompassTemplate(CompassTemplate compassTemplate)
          Sets the CompassTemplate used by the DAO explicitly.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected final org.apache.commons.logging.Log log
Constructor Detail

CompassDaoSupport

public CompassDaoSupport()
Method Detail

setCompass

public final void setCompass(Compass compass)
Sets the Compass to be used by this DAO. Will automatically create a CompassTemplate based on the given Compass.

Parameters:
compass -

createCompassTemplate

protected CompassTemplate createCompassTemplate(Compass compass)
Creates a new CompassTemplate based on the provided Compass. Subclasses can override it to create a subclass of CompassTemplate, or change the configuration.

The method is only called when initializing the dao with Compass instance and not a CompassTemplate instance.

Parameters:
compass -
Returns:
A new CompassTemplate warpping the given Compass instance.

getCompass

public final Compass getCompass()
Returns the Compass used by the DAO.

Returns:
compass instance used by the DAO

setCompassTemplate

public final void setCompassTemplate(CompassTemplate compassTemplate)
Sets the CompassTemplate used by the DAO explicitly. It is an alternative to setting the Compass directly.

Parameters:
compassTemplate -

getCompassTemplate

public final CompassTemplate getCompassTemplate()
Returns the CompassTemplate for this DAO. Pre-initialized with Compass or set explicitly.

Returns:
The compass template for the DAO

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
Exception

initDao

protected void initDao()
                throws Exception
Throws:
Exception


Copyright (c) 2004-2008 The Compass Project.