@Configuration @PropertySource(value="file:${user.home}/.cdmLibrary/cdmlib-remote.properties", ignoreResourceNotFound=true) public class DataSourceConfigurer extends AbstractWebApplicationConfigurer
DataSourceConfigurer
can be used as a replacement for a xml configuration in the application context.
The id of the loaded data source bean aka the cdm instance name is put into the Spring environment from where it can be retrieved using the
key CDM_DATA_SOURCE_ID
.
Enter the following in your application context configuration in order to enable the DataSourceConfigurer
:
<!-- enable processing of annotations such as @Autowired and @Configuration --> <context:annotation-config/> <bean class="eu.etaxonomy.cdm.remote.config.DataSourceConfigurer" > </bean>The
DataSourceConfigurer
allows alternative ways to specify a data source:
-Dcdm.datasource={dataSourceName}
(ATTRIBUTE_DATASOURCE_NAME
).
The data source bean with the given name will then be loaded from the cdm.beanDefinitionFile
(CDM_BEAN_DEFINITION_FILE
), which must be a valid Spring bean definition file.
ATTRIBUTE_JDBC_JNDI_NAME
as attribute to the ServletContext.
This scenario usually being used by the cdm-server application.
AbstractWebApplicationConfigurer.findProperty(String, boolean)
.Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
ATTRIBUTE_DATASOURCE_NAME
Attribute to configure the name of the data source as set as bean name in the datasources.xml.
|
static java.lang.String |
ATTRIBUTE_FORCE_SCHEMA_UPDATE
Force a schema update when the cdmlib-remote-webapp instance is starting up
see also
eu.etaxonomy.cdm.server.instance.SharedAttributes.ATTRIBUTE_FORCE_SCHEMA_UPDATE |
static java.lang.String |
ATTRIBUTE_JDBC_JNDI_NAME
see also
eu.etaxonomy.cdm.server.instance.SharedAttributes |
protected static java.lang.String |
CDM_BEAN_DEFINITION_FILE |
static java.lang.String |
CDM_DATA_SOURCE_ID
Deprecated.
use CdmConfigurationKeys.CDM_DATA_SOURCE_ID instead
|
protected static java.lang.String |
HIBERNATE_DIALECT |
protected static java.lang.String |
HIBERNATE_SEARCH_DEFAULT_INDEX_BASE |
static Logger |
logger |
env, webApplicationContext
Constructor and Description |
---|
DataSourceConfigurer() |
Modifier and Type | Method and Description |
---|---|
javax.sql.DataSource |
dataSource() |
DataSourceProperties |
dataSourceProperties() |
java.lang.String |
getBeanDefinitionFile() |
java.util.Properties |
hibernateProperties() |
java.lang.String |
inferHibernateDialectName()
Returns the full class name of the according
Dialect implementation |
java.lang.String |
inferHibernateDialectName(javax.sql.DataSource ds)
Returns the full class name of the according
Dialect implementation |
void |
setBeanDefinitionFile(java.lang.String filename)
The file to load the
DataSource beans from. |
addErrorMessageToServletContextAttributes, afterPropertiesSet, findProperty, setApplicationContext
public static final Logger logger
protected static final java.lang.String HIBERNATE_DIALECT
protected static final java.lang.String HIBERNATE_SEARCH_DEFAULT_INDEX_BASE
protected static final java.lang.String CDM_BEAN_DEFINITION_FILE
@Deprecated public static final java.lang.String CDM_DATA_SOURCE_ID
protected static final java.lang.String ATTRIBUTE_DATASOURCE_NAME
public static final java.lang.String ATTRIBUTE_JDBC_JNDI_NAME
eu.etaxonomy.cdm.server.instance.SharedAttributes
public static final java.lang.String ATTRIBUTE_FORCE_SCHEMA_UPDATE
eu.etaxonomy.cdm.server.instance.SharedAttributes.ATTRIBUTE_FORCE_SCHEMA_UPDATE
public void setBeanDefinitionFile(java.lang.String filename)
DataSource
beans from.
This file is usually ${user.home}/.cdmLibrary/datasources.xml
The variable ${user.home}
is determined by ConfigFileUtil.getCdmHomeDir()
filename
- public java.lang.String getBeanDefinitionFile()
@Bean @Order(value=-2147483648) public javax.sql.DataSource dataSource()
@Bean public DataSourceProperties dataSourceProperties()
@Bean public java.util.Properties hibernateProperties()
public java.lang.String inferHibernateDialectName()
Dialect
implementationds
- the DataSourcepublic java.lang.String inferHibernateDialectName(javax.sql.DataSource ds)
Dialect
implementationds
- the DataSourceCopyright © 2007-2020 EDIT. All Rights Reserved.