Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
making repo-sql-impl non-required for starting with another repo impl
- MP still starts configured with old repo and audit, which is a must. - new sqale-repo is not working at all yet - task-impl does not fail on Spring bean deps, but on new repo - SystemConfigurationChangeDispatcherImpl moved to repo-common It was in repo-sql-impl previously, but it supports any repo impl. - SqlAuditServiceFactory is conditionally created by @configuration SqlRepositoryBeanConfig. Previous @conditional... on SASF did not work. - bare SqaleRepositoryBeanConfig was introduced + new ctx-repository.xml
- Loading branch information
Showing
10 changed files
with
195 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
...temConfigurationChangeDispatcherImpl.java → ...temConfigurationChangeDispatcherImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
.../repo-sqale/src/main/java/com/evolveum/midpoint/repo/sqale/SqaleRepositoryBeanConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
/* | ||
* Copyright (C) 2010-2020 Evolveum and contributors | ||
* | ||
* This work is dual-licensed under the Apache License 2.0 | ||
* and European Union Public License. See LICENSE file for details. | ||
*/ | ||
package com.evolveum.midpoint.repo.sqale; | ||
|
||
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.ComponentScan; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
import com.evolveum.midpoint.repo.sqlbase.SqlRepoContext; | ||
|
||
/** | ||
* New SQL repository related configuration. | ||
* {@link ConditionalOnMissingBean} annotations are used to avoid duplicate bean acquirement that | ||
* would happen when combined with alternative configurations (e.g. context XMLs for test). | ||
* {@link ConditionalOnExpression} class annotation activates this configuration only if midpoint | ||
* {@code config.xml} specifies the repository factory class from SQL package. | ||
*/ | ||
@Configuration | ||
@ConditionalOnExpression("#{midpointConfiguration.getConfiguration('midpoint.repository')" | ||
+ ".getString('repositoryServiceFactoryClass').startsWith('com.evolveum.midpoint.repo.sqale.')}") | ||
@ComponentScan | ||
public class SqaleRepositoryBeanConfig { | ||
|
||
@Bean | ||
public SqlRepoContext sqlRepoContext() { | ||
// TODO fill in | ||
return new SqlRepoContext(null, null); | ||
} | ||
|
||
/* | ||
@Bean | ||
@ConditionalOnMissingBean | ||
public DataSourceFactory dataSourceFactory(SqlRepositoryFactory sqlRepositoryFactory) { | ||
return new DataSourceFactory(sqlRepositoryFactory.getSqlConfiguration()); | ||
} | ||
@Bean | ||
@ConditionalOnMissingBean | ||
public DataSource dataSource(DataSourceFactory dataSourceFactory) | ||
throws RepositoryServiceFactoryException { | ||
return dataSourceFactory.createDataSource(); | ||
} | ||
@Bean | ||
public MidPointImplicitNamingStrategy midPointImplicitNamingStrategy() { | ||
return new MidPointImplicitNamingStrategy(); | ||
} | ||
@Bean | ||
public MidPointPhysicalNamingStrategy midPointPhysicalNamingStrategy() { | ||
return new MidPointPhysicalNamingStrategy(); | ||
} | ||
@Bean | ||
public EntityStateInterceptor entityStateInterceptor() { | ||
return new EntityStateInterceptor(); | ||
} | ||
@Bean | ||
public LocalSessionFactoryBean sessionFactory( | ||
DataSource dataSource, | ||
DataSourceFactory dataSourceFactory, | ||
MidPointImplicitNamingStrategy midPointImplicitNamingStrategy, | ||
MidPointPhysicalNamingStrategy midPointPhysicalNamingStrategy, | ||
EntityStateInterceptor entityStateInterceptor) { | ||
LocalSessionFactoryBean bean = new LocalSessionFactoryBean(); | ||
SqlRepositoryConfiguration configuration = dataSourceFactory.configuration(); | ||
// While dataSource == dataSourceFactory.getDataSource(), we're using dataSource as | ||
// parameter to assure, that Spring already called the factory method. Explicit is good. | ||
bean.setDataSource(dataSource); | ||
Properties hibernateProperties = new Properties(); | ||
hibernateProperties.setProperty("hibernate.dialect", configuration.getHibernateDialect()); | ||
hibernateProperties.setProperty("hibernate.hbm2ddl.auto", configuration.getHibernateHbm2ddl()); | ||
hibernateProperties.setProperty("hibernate.id.new_generator_mappings", "true"); | ||
hibernateProperties.setProperty("hibernate.jdbc.batch_size", "20"); | ||
hibernateProperties.setProperty("javax.persistence.validation.mode", "none"); | ||
hibernateProperties.setProperty("hibernate.transaction.coordinator_class", "jdbc"); | ||
hibernateProperties.setProperty("hibernate.hql.bulk_id_strategy", | ||
"org.hibernate.hql.spi.id.inline.InlineIdsOrClauseBulkIdStrategy"); | ||
bean.setHibernateProperties(hibernateProperties); | ||
bean.setImplicitNamingStrategy(midPointImplicitNamingStrategy); | ||
bean.setPhysicalNamingStrategy(midPointPhysicalNamingStrategy); | ||
bean.setAnnotatedPackages("com.evolveum.midpoint.repo.sql.type"); | ||
bean.setPackagesToScan( | ||
"com.evolveum.midpoint.repo.sql.data.common", | ||
"com.evolveum.midpoint.repo.sql.data.common.any", | ||
"com.evolveum.midpoint.repo.sql.data.common.container", | ||
"com.evolveum.midpoint.repo.sql.data.common.embedded", | ||
"com.evolveum.midpoint.repo.sql.data.common.enums", | ||
"com.evolveum.midpoint.repo.sql.data.common.id", | ||
"com.evolveum.midpoint.repo.sql.data.common.other", | ||
"com.evolveum.midpoint.repo.sql.data.common.type", | ||
"com.evolveum.midpoint.repo.sql.data.audit"); | ||
bean.setEntityInterceptor(entityStateInterceptor); | ||
return bean; | ||
} | ||
@Bean | ||
public TransactionManager transactionManager(SessionFactory sessionFactory) { | ||
HibernateTransactionManager htm = new HibernateTransactionManager(); | ||
htm.setSessionFactory(sessionFactory); | ||
return htm; | ||
} | ||
*/ | ||
|
||
// TODO @Bean for AuditServiceFactory | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Copyright (C) 2010-2021 Evolveum and contributors | ||
~ | ||
~ This work is dual-licensed under the Apache License 2.0 | ||
~ and European Union Public License. See LICENSE file for details. | ||
--> | ||
|
||
<beans xmlns="http://www.springframework.org/schema/beans" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://www.springframework.org/schema/beans | ||
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd" | ||
default-lazy-init="true"> | ||
|
||
<!-- This @Configuration drives component-scan + can use @Conditional... --> | ||
<bean id="sqaleRepositoryBeanConfig" class="com.evolveum.midpoint.repo.sqale.SqaleRepositoryBeanConfig"/> | ||
</beans> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters