org.ow2.dragon.persistence.util
Class ExtendedLocalCompassBean

java.lang.Object
  extended by org.ow2.dragon.persistence.util.ExtendedLocalCompassBean
All Implemented Interfaces:
org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.FactoryBean, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware, org.springframework.context.ResourceLoaderAware

public class ExtendedLocalCompassBean
extends java.lang.Object
implements org.springframework.beans.factory.FactoryBean, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.BeanNameAware, org.springframework.context.ApplicationContextAware, org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.context.ResourceLoaderAware

Author:
ofabre - eBM Websourcing

Field Summary
protected static org.apache.commons.logging.Log log
           
 
Constructor Summary
ExtendedLocalCompassBean()
           
 
Method Summary
 void afterPropertiesSet()
           
 void destroy()
           
protected  java.lang.ClassLoader getClassLoader()
           
 java.lang.Object getObject()
           
 java.lang.Class getObjectType()
           
 boolean isSingleton()
           
protected  org.compass.core.Compass newCompass(org.compass.core.config.CompassConfiguration config)
           
protected  org.compass.core.config.CompassConfiguration newConfiguration()
           
protected  void scanPackages(org.compass.core.config.CompassConfiguration config)
          Perform Spring-based scanning for entity classes.
 void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
           
 void setBeanClassLoader(java.lang.ClassLoader classLoader)
           
 void setBeanName(java.lang.String beanName)
           
 void setClassMappings(java.lang.String[] classMappings)
          Sets the fully qualified class names for mappings.
 void setCompassConfiguration(org.compass.core.config.CompassConfiguration config)
           
 void setCompassSettings(java.util.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(java.util.Map<java.lang.String,org.compass.core.converter.Converter> convertersByName)
          Sets a map of global converters to be registered with compass.
 void setDataSource(javax.sql.DataSource dataSource)
          Sets a DataSource to be used when the index is stored within a database.
 void setMappingResolvers(org.compass.core.config.InputStreamMappingResolver[] mappingResolvers)
          Sets the mapping resolvers the resolved Compass mapping definitions.
 void setMappingScan(java.lang.String basePackage)
           
 void setPackagesToScan(java.lang.String[] packagesToScan)
          Set whether to use Spring-based scanning for entity classes in the classpath instead of listing annotated classes explicitly.
 void setPostProcessor(org.compass.spring.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 setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)
           
 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(java.util.Map<java.lang.String,java.lang.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

ExtendedLocalCompassBean

public ExtendedLocalCompassBean()
Method Detail

setPackagesToScan

public void setPackagesToScan(java.lang.String[] packagesToScan)
Set whether to use Spring-based scanning for entity classes in the classpath instead of listing annotated classes explicitly.

Default is none. Specify packages to search for autodetection of your entity classes in the classpath. This is analogous to Spring's component-scan feature ( org.springframework.context.annotation.ClassPathBeanDefinitionScanner ).


setResourceLoader

public void setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)
Specified by:
setResourceLoader in interface org.springframework.context.ResourceLoaderAware

setPostProcessor

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


setBeanName

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

setApplicationContext

public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
                           throws org.springframework.beans.BeansException
Specified by:
setApplicationContext in interface org.springframework.context.ApplicationContextAware
Throws:
org.springframework.beans.BeansException

setBeanClassLoader

public void setBeanClassLoader(java.lang.ClassLoader classLoader)
Specified by:
setBeanClassLoader in interface org.springframework.beans.factory.BeanClassLoaderAware

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.


setMappingScan

public void setMappingScan(java.lang.String basePackage)
See Also:
CompassConfiguration.addScan(String)

setCompassSettings

public void setCompassSettings(java.util.Properties compassSettings)

setSettings

public void setSettings(java.util.Map<java.lang.String,java.lang.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(java.lang.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(org.compass.core.config.InputStreamMappingResolver[] mappingResolvers)
Sets the mapping resolvers the resolved Compass mapping definitions.


setDataSource

public void setDataSource(javax.sql.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(java.util.Map<java.lang.String,org.compass.core.converter.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(org.compass.core.config.CompassConfiguration config)

afterPropertiesSet

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

newConfiguration

protected org.compass.core.config.CompassConfiguration newConfiguration()

newCompass

protected org.compass.core.Compass newCompass(org.compass.core.config.CompassConfiguration config)
                                       throws org.compass.core.CompassException
Throws:
org.compass.core.CompassException

getObject

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

getObjectType

public java.lang.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 java.lang.Exception
Specified by:
destroy in interface org.springframework.beans.factory.DisposableBean
Throws:
java.lang.Exception

getClassLoader

protected java.lang.ClassLoader getClassLoader()

scanPackages

protected void scanPackages(org.compass.core.config.CompassConfiguration config)
Perform Spring-based scanning for entity classes.

See Also:
setPackagesToScan(java.lang.String[])


Copyright © 2008-2009 eBMWebsourcing. All Rights Reserved.