some renaming

This commit is contained in:
Tadgh 2020-06-15 21:49:34 -07:00
parent 9222fa3f59
commit d32ad74402
5 changed files with 91 additions and 7 deletions

View File

@ -8,7 +8,7 @@ import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
import ca.uhn.fhir.jpa.api.dao.IDao; import ca.uhn.fhir.jpa.api.dao.IDao;
import ca.uhn.fhir.jpa.batch.BatchJobsConfig; import ca.uhn.fhir.jpa.batch.BatchJobsConfig;
import ca.uhn.fhir.jpa.batch.api.IBatchJobSubmitter; import ca.uhn.fhir.jpa.batch.api.IBatchJobSubmitter;
import ca.uhn.fhir.jpa.batch.config.InMemoryJobRepositoryBatchConfig; import ca.uhn.fhir.jpa.batch.config.NonPersistedBatchConfigurer;
import ca.uhn.fhir.jpa.batch.svc.BatchJobSubmitterImpl; import ca.uhn.fhir.jpa.batch.svc.BatchJobSubmitterImpl;
import ca.uhn.fhir.jpa.binstore.BinaryAccessProvider; import ca.uhn.fhir.jpa.binstore.BinaryAccessProvider;
import ca.uhn.fhir.jpa.binstore.BinaryStorageInterceptor; import ca.uhn.fhir.jpa.binstore.BinaryStorageInterceptor;
@ -28,8 +28,8 @@ import ca.uhn.fhir.jpa.model.sched.ISchedulerService;
import ca.uhn.fhir.jpa.packages.IHapiPackageCacheManager; import ca.uhn.fhir.jpa.packages.IHapiPackageCacheManager;
import ca.uhn.fhir.jpa.packages.IPackageInstallerSvc; import ca.uhn.fhir.jpa.packages.IPackageInstallerSvc;
import ca.uhn.fhir.jpa.packages.JpaPackageCache; import ca.uhn.fhir.jpa.packages.JpaPackageCache;
import ca.uhn.fhir.jpa.packages.PackageInstallerSvcImpl;
import ca.uhn.fhir.jpa.packages.NpmJpaValidationSupport; import ca.uhn.fhir.jpa.packages.NpmJpaValidationSupport;
import ca.uhn.fhir.jpa.packages.PackageInstallerSvcImpl;
import ca.uhn.fhir.jpa.partition.IPartitionLookupSvc; import ca.uhn.fhir.jpa.partition.IPartitionLookupSvc;
import ca.uhn.fhir.jpa.partition.IRequestPartitionHelperSvc; import ca.uhn.fhir.jpa.partition.IRequestPartitionHelperSvc;
import ca.uhn.fhir.jpa.partition.PartitionLookupSvcImpl; import ca.uhn.fhir.jpa.partition.PartitionLookupSvcImpl;
@ -63,6 +63,8 @@ import org.hibernate.jpa.HibernatePersistenceProvider;
import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.utilities.cache.FilesystemPackageCacheManager; import org.hl7.fhir.utilities.cache.FilesystemPackageCacheManager;
import org.hl7.fhir.utilities.graphql.IGraphQLStorageServices; import org.hl7.fhir.utilities.graphql.IGraphQLStorageServices;
import org.springframework.batch.core.configuration.annotation.BatchConfigurer;
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
@ -119,8 +121,9 @@ import java.util.Date;
@ComponentScan.Filter(type = FilterType.REGEX, pattern = "ca.uhn.fhir.jpa.batch.*") @ComponentScan.Filter(type = FilterType.REGEX, pattern = "ca.uhn.fhir.jpa.batch.*")
}) })
@Import({ @Import({
SearchParamConfig.class, BatchJobsConfig.class, InMemoryJobRepositoryBatchConfig.class SearchParamConfig.class, BatchJobsConfig.class
}) })
@EnableBatchProcessing
public abstract class BaseConfig { public abstract class BaseConfig {
public static final String JPA_VALIDATION_SUPPORT_CHAIN = "myJpaValidationSupportChain"; public static final String JPA_VALIDATION_SUPPORT_CHAIN = "myJpaValidationSupportChain";
@ -138,6 +141,11 @@ public abstract class BaseConfig {
@Autowired @Autowired
private DaoRegistry myDaoRegistry; private DaoRegistry myDaoRegistry;
@Bean
public BatchConfigurer batchConfigurer() {
return new NonPersistedBatchConfigurer();
}
@Bean("myDaoRegistry") @Bean("myDaoRegistry")
public DaoRegistry daoRegistry() { public DaoRegistry daoRegistry() {
return new DaoRegistry(); return new DaoRegistry();

View File

@ -21,7 +21,6 @@ package ca.uhn.fhir.jpa.batch.config;
*/ */
import org.springframework.batch.core.configuration.annotation.BatchConfigurer; import org.springframework.batch.core.configuration.annotation.BatchConfigurer;
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
import org.springframework.batch.core.explore.JobExplorer; import org.springframework.batch.core.explore.JobExplorer;
import org.springframework.batch.core.explore.support.MapJobExplorerFactoryBean; import org.springframework.batch.core.explore.support.MapJobExplorerFactoryBean;
import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.launch.JobLauncher;
@ -30,11 +29,12 @@ import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean; import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean;
import org.springframework.batch.support.transaction.ResourcelessTransactionManager; import org.springframework.batch.support.transaction.ResourcelessTransactionManager;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.PlatformTransactionManager;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
@EnableBatchProcessing @Component
@Configuration @Configuration
public class InMemoryJobRepositoryBatchConfig implements BatchConfigurer { public class InMemoryJobRepositoryBatchConfig implements BatchConfigurer {
@ -43,6 +43,7 @@ public class InMemoryJobRepositoryBatchConfig implements BatchConfigurer {
private JobRepository myJobRepository; private JobRepository myJobRepository;
private JobExplorer myJobExplorer; private JobExplorer myJobExplorer;
@Override @Override
public PlatformTransactionManager getTransactionManager() { public PlatformTransactionManager getTransactionManager() {
return myPlatformTransactionManager; return myPlatformTransactionManager;

View File

@ -0,0 +1,60 @@
package ca.uhn.fhir.jpa.batch.config;
/*-
* #%L
* HAPI FHIR JPA Server - Batch Task Processor
* %%
* Copyright (C) 2014 - 2020 University Health Network
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import org.springframework.batch.core.configuration.annotation.DefaultBatchConfigurer;
import org.springframework.batch.core.explore.JobExplorer;
import org.springframework.batch.core.explore.support.MapJobExplorerFactoryBean;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean;
import org.springframework.batch.support.transaction.ResourcelessTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;
public class NonPersistedBatchConfigurer extends DefaultBatchConfigurer {
private PlatformTransactionManager myPlatformTransactionManager;
private MapJobRepositoryFactoryBean myJobRepositoryFactory;
@Override
public PlatformTransactionManager getTransactionManager() {
if (myPlatformTransactionManager == null) {
myPlatformTransactionManager = new ResourcelessTransactionManager();
}
return myPlatformTransactionManager;
}
@Override
protected JobRepository createJobRepository() throws Exception {
MapJobRepositoryFactoryBean factory = new MapJobRepositoryFactoryBean();
factory.setTransactionManager(this.getTransactionManager());
factory.afterPropertiesSet();
myJobRepositoryFactory = factory;
return factory.getObject();
}
@Override
public JobExplorer createJobExplorer() throws Exception {
MapJobExplorerFactoryBean jobExplorerFactoryBean = new MapJobExplorerFactoryBean(myJobRepositoryFactory);
jobExplorerFactoryBean.afterPropertiesSet();
return jobExplorerFactoryBean.getObject();
}
}

View File

@ -1,7 +1,7 @@
package ca.uhn.fhir.jpa.batch; package ca.uhn.fhir.jpa.batch;
import ca.uhn.fhir.jpa.batch.config.BatchJobConfig; import ca.uhn.fhir.jpa.batch.config.BatchJobConfig;
import ca.uhn.fhir.jpa.batch.config.InMemoryJobRepositoryBatchConfig; import ca.uhn.fhir.jpa.batch.config.TestBatchConfig;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.springframework.batch.core.Job; import org.springframework.batch.core.Job;
@ -14,7 +14,7 @@ import org.springframework.transaction.PlatformTransactionManager;
import static org.slf4j.LoggerFactory.getLogger; import static org.slf4j.LoggerFactory.getLogger;
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@ContextConfiguration(classes = {BatchJobConfig.class, InMemoryJobRepositoryBatchConfig.class}) @ContextConfiguration(classes = {BatchJobConfig.class, TestBatchConfig.class})
abstract public class BaseBatchR4Test { abstract public class BaseBatchR4Test {
private static final Logger ourLog = getLogger(BaseBatchR4Test.class); private static final Logger ourLog = getLogger(BaseBatchR4Test.class);

View File

@ -0,0 +1,15 @@
package ca.uhn.fhir.jpa.batch.config;
import org.springframework.batch.core.configuration.annotation.BatchConfigurer;
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
@EnableBatchProcessing
public class TestBatchConfig {
@Bean
public BatchConfigurer batchConfigurer() {
return new NonPersistedBatchConfigurer();
}
}