org.compass.spring
Class LocalCompassBean

java.lang.Object
  extended by org.compass.spring.LocalCompassBean
All Implemented Interfaces:
org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.FactoryBean, org.springframework.beans.factory.InitializingBean

public class LocalCompassBean
extends Object
implements org.springframework.beans.factory.FactoryBean, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.BeanNameAware

Author:
kimchy

Field Summary
protected static org.apache.commons.logging.Log log
           
 
Constructor Summary
LocalCompassBean()
           
 
Method Summary
 void afterPropertiesSet()
           
 void destroy()
           
protected  ClassLoader getClassLoader()
           
 Object getObject()
           
 Class getObjectType()
           
 boolean isSingleton()
           
protected  Compass newCompass(CompassConfiguration config)
           
protected  CompassConfiguration newConfiguration()
           
 void setBeanName(String beanName)
           
 void setClassMappings(String[] classMappings)
          Sets the fully qualified class names for mappings.
 void setCompassConfiguration(CompassConfiguration config)
           
 void setCompassSettings(Properties compassSettings)
           
 void setConfigLocation(org.springframework.core.io.Resource configLocation)
          Set the location of the Compass XML config file, for example as classpath resource "classpath:compass.cfg.xml".
 void setConfigLocations(org.springframework.core.io.Resource[] configLocations)
          Set the location of the Compass XML config file, for example as classpath resource "classpath:compass.cfg.xml".
 void setConnection(org.springframework.core.io.Resource connection)
          Sets an optional connection based on Spring Resource abstraction.
 void setConvertersByName(Map<String,Converter> convertersByName)
          Sets a map of global converters to be registered with compass.
 void setDataSource(DataSource dataSource)
          Sets a DataSource to be used when the index is stored within a database.
 void setMappingResolvers(InputStreamMappingResolver[] mappingResolvers)
          Sets the mapping resolvers the resolved Compass mapping definitions.
 void setPostProcessor(LocalCompassBeanPostProcessor postProcessor)
          Allows to register a post processor for the Compass configuration.
 void setResourceDirectoryLocations(org.springframework.core.io.Resource[] resourceDirectoryLocations)
          Set locations of directories that contain Compass mapping resources, like "WEB-INF/mappings".
 void setResourceJarLocations(org.springframework.core.io.Resource[] resourceJarLocations)
          Set locations of jar files that contain Compass resources, like "WEB-INF/lib/example.jar".
 void setResourceLocations(org.springframework.core.io.Resource[] resourceLocations)
          Set locations of Compass resource files (mapping and common metadata), for example as classpath resource "classpath:example.cpm.xml".
 void setSettings(Map<String,Object> settings)
           
 void setTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager)
          Sets Spring PlatformTransactionManager to be used with compass.
 
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

LocalCompassBean

public LocalCompassBean()
Method Detail

setPostProcessor

public void setPostProcessor(LocalCompassBeanPostProcessor postProcessor)
Allows to register a post processor for the Compass configuration.


setBeanName

public void setBeanName(String beanName)
Specified by:
setBeanName in interface org.springframework.beans.factory.BeanNameAware

setConnection

public void setConnection(org.springframework.core.io.Resource connection)
Sets an optional connection based on Spring Resource abstraction. Will be used if none is set as part of other possible configuration of Compass connection.

Will use Resource#getFile in order to get the absolute path.


setConfigLocation

public void setConfigLocation(org.springframework.core.io.Resource configLocation)
Set the location of the Compass XML config file, for example as classpath resource "classpath:compass.cfg.xml".

Note: Can be omitted when all necessary properties and mapping resources are specified locally via this bean.


setConfigLocations

public void setConfigLocations(org.springframework.core.io.Resource[] configLocations)
Set the location of the Compass XML config file, for example as classpath resource "classpath:compass.cfg.xml".

Note: Can be omitted when all necessary properties and mapping resources are specified locally via this bean.


setCompassSettings

public void setCompassSettings(Properties compassSettings)

setSettings

public void setSettings(Map<String,Object> settings)

setResourceLocations

public void setResourceLocations(org.springframework.core.io.Resource[] resourceLocations)
Set locations of Compass resource files (mapping and common metadata), for example as classpath resource "classpath:example.cpm.xml". Supports any resource location via Spring's resource abstraction, for example relative paths like "WEB-INF/mappings/example.hbm.xml" when running in an application context.

Can be used to add to mappings from a Compass XML config file, or to specify all mappings locally.


setResourceJarLocations

public void setResourceJarLocations(org.springframework.core.io.Resource[] resourceJarLocations)
Set locations of jar files that contain Compass resources, like "WEB-INF/lib/example.jar".

Can be used to add to mappings from a Compass XML config file, or to specify all mappings locally.


setResourceDirectoryLocations

public void setResourceDirectoryLocations(org.springframework.core.io.Resource[] resourceDirectoryLocations)
Set locations of directories that contain Compass mapping resources, like "WEB-INF/mappings".

Can be used to add to mappings from a Compass XML config file, or to specify all mappings locally.


setClassMappings

public void setClassMappings(String[] classMappings)
Sets the fully qualified class names for mappings. Useful when using annotations for example. Will also try to load the matching "[Class].cpm.xml" file.


setMappingResolvers

public void setMappingResolvers(InputStreamMappingResolver[] mappingResolvers)
Sets the mapping resolvers the resolved Compass mapping definitions.


setDataSource

public void setDataSource(DataSource dataSource)
Sets a DataSource to be used when the index is stored within a database. The data source must be used with ExternalDataSourceProvider for externally configured data sources (such is the case some of the time with spring). If set, Compass data source provider does not have to be set, since it will automatically default to ExternalDataSourceProvider. If the compass data source provider is set as a compass setting, it will be used.

Note, that it will be automatically wrapped with Spring's TransactionAwareDataSourceProxy if not already wrapped by one. TransactionAwareDataSourceProxy.

Also note that setting the data source is not enough to configure Compass to store the index within the database, the Compass connection string should also be set to jdbc://.


setTransactionManager

public void setTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager)
Sets Spring PlatformTransactionManager to be used with compass. If using SpringSyncTransactionFactory, it must be set.


setConvertersByName

public void setConvertersByName(Map<String,Converter> convertersByName)
Sets a map of global converters to be registered with compass. The map key will be the name that the converter will be registered against, and the value should be the Converter itself (natuarally configured using spring DI).


setCompassConfiguration

public void setCompassConfiguration(CompassConfiguration config)

afterPropertiesSet

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

newConfiguration

protected CompassConfiguration newConfiguration()

newCompass

protected Compass newCompass(CompassConfiguration config)
                      throws CompassException
Throws:
CompassException

getObject

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

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

destroy

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

getClassLoader

protected ClassLoader getClassLoader()


Copyright (c) 2004-2008 The Compass Project.