001/* 002 * #%L 003 * HAPI FHIR JPA Server 004 * %% 005 * Copyright (C) 2014 - 2025 Smile CDR, Inc. 006 * %% 007 * Licensed under the Apache License, Version 2.0 (the "License"); 008 * you may not use this file except in compliance with the License. 009 * You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, software 014 * distributed under the License is distributed on an "AS IS" BASIS, 015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 016 * See the License for the specific language governing permissions and 017 * limitations under the License. 018 * #L% 019 */ 020package ca.uhn.fhir.jpa.config; 021 022import ca.uhn.fhir.batch2.api.IJobCoordinator; 023import ca.uhn.fhir.batch2.api.IJobPersistence; 024import ca.uhn.fhir.batch2.jobs.export.BulkDataExportProvider; 025import ca.uhn.fhir.batch2.jobs.expunge.DeleteExpungeJobSubmitterImpl; 026import ca.uhn.fhir.batch2.util.Batch2TaskHelper; 027import ca.uhn.fhir.context.FhirContext; 028import ca.uhn.fhir.context.FhirVersionEnum; 029import ca.uhn.fhir.context.support.IValidationSupport; 030import ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster; 031import ca.uhn.fhir.interceptor.api.IInterceptorService; 032import ca.uhn.fhir.interceptor.executor.InterceptorService; 033import ca.uhn.fhir.interceptor.model.RequestPartitionId; 034import ca.uhn.fhir.jpa.api.config.JpaStorageSettings; 035import ca.uhn.fhir.jpa.api.dao.DaoRegistry; 036import ca.uhn.fhir.jpa.api.model.ExpungeOptions; 037import ca.uhn.fhir.jpa.api.svc.IIdHelperService; 038import ca.uhn.fhir.jpa.api.svc.ISearchUrlJobMaintenanceSvc; 039import ca.uhn.fhir.jpa.binary.interceptor.BinaryStorageInterceptor; 040import ca.uhn.fhir.jpa.binary.provider.BinaryAccessProvider; 041import ca.uhn.fhir.jpa.bulk.export.api.IBulkDataExportJobSchedulingHelper; 042import ca.uhn.fhir.jpa.bulk.export.svc.BulkDataExportJobSchedulingHelperImpl; 043import ca.uhn.fhir.jpa.bulk.export.svc.BulkExportHelperService; 044import ca.uhn.fhir.jpa.bulk.imprt.api.IBulkDataImportSvc; 045import ca.uhn.fhir.jpa.bulk.imprt.svc.BulkDataImportSvcImpl; 046import ca.uhn.fhir.jpa.cache.IResourceVersionSvc; 047import ca.uhn.fhir.jpa.cache.ResourceVersionSvcDaoImpl; 048import ca.uhn.fhir.jpa.dao.CacheTagDefinitionDao; 049import ca.uhn.fhir.jpa.dao.DaoSearchParamProvider; 050import ca.uhn.fhir.jpa.dao.HistoryBuilder; 051import ca.uhn.fhir.jpa.dao.HistoryBuilderFactory; 052import ca.uhn.fhir.jpa.dao.IFulltextSearchSvc; 053import ca.uhn.fhir.jpa.dao.IJpaStorageResourceParser; 054import ca.uhn.fhir.jpa.dao.ISearchBuilder; 055import ca.uhn.fhir.jpa.dao.JpaStorageResourceParser; 056import ca.uhn.fhir.jpa.dao.MatchResourceUrlService; 057import ca.uhn.fhir.jpa.dao.ResourceHistoryCalculator; 058import ca.uhn.fhir.jpa.dao.SearchBuilderFactory; 059import ca.uhn.fhir.jpa.dao.TransactionProcessor; 060import ca.uhn.fhir.jpa.dao.data.IResourceLinkDao; 061import ca.uhn.fhir.jpa.dao.data.IResourceModifiedDao; 062import ca.uhn.fhir.jpa.dao.data.IResourceSearchUrlDao; 063import ca.uhn.fhir.jpa.dao.data.ITagDefinitionDao; 064import ca.uhn.fhir.jpa.dao.expunge.ExpungeEverythingService; 065import ca.uhn.fhir.jpa.dao.expunge.ExpungeOperation; 066import ca.uhn.fhir.jpa.dao.expunge.ExpungeService; 067import ca.uhn.fhir.jpa.dao.expunge.IExpungeEverythingService; 068import ca.uhn.fhir.jpa.dao.expunge.IResourceExpungeService; 069import ca.uhn.fhir.jpa.dao.expunge.JpaResourceExpungeService; 070import ca.uhn.fhir.jpa.dao.expunge.ResourceTableFKProvider; 071import ca.uhn.fhir.jpa.dao.index.DaoResourceLinkResolver; 072import ca.uhn.fhir.jpa.dao.index.DaoSearchParamSynchronizer; 073import ca.uhn.fhir.jpa.dao.index.IdHelperService; 074import ca.uhn.fhir.jpa.dao.index.SearchParamWithInlineReferencesExtractor; 075import ca.uhn.fhir.jpa.dao.tx.HapiTransactionService; 076import ca.uhn.fhir.jpa.dao.validation.SearchParameterDaoValidator; 077import ca.uhn.fhir.jpa.delete.DeleteConflictFinderService; 078import ca.uhn.fhir.jpa.delete.DeleteConflictService; 079import ca.uhn.fhir.jpa.delete.ThreadSafeResourceDeleterSvc; 080import ca.uhn.fhir.jpa.entity.Search; 081import ca.uhn.fhir.jpa.entity.TermValueSet; 082import ca.uhn.fhir.jpa.esr.ExternallyStoredResourceServiceRegistry; 083import ca.uhn.fhir.jpa.graphql.DaoRegistryGraphQLStorageServices; 084import ca.uhn.fhir.jpa.interceptor.CascadingDeleteInterceptor; 085import ca.uhn.fhir.jpa.interceptor.JpaConsentContextServices; 086import ca.uhn.fhir.jpa.interceptor.OverridePathBasedReferentialIntegrityForDeletesInterceptor; 087import ca.uhn.fhir.jpa.interceptor.validation.RepositoryValidatingRuleBuilder; 088import ca.uhn.fhir.jpa.model.config.PartitionSettings; 089import ca.uhn.fhir.jpa.model.dao.JpaPid; 090import ca.uhn.fhir.jpa.model.sched.ISchedulerService; 091import ca.uhn.fhir.jpa.packages.IHapiPackageCacheManager; 092import ca.uhn.fhir.jpa.packages.IPackageInstallerSvc; 093import ca.uhn.fhir.jpa.packages.JpaPackageCache; 094import ca.uhn.fhir.jpa.packages.NpmJpaValidationSupport; 095import ca.uhn.fhir.jpa.packages.PackageInstallerSvcImpl; 096import ca.uhn.fhir.jpa.packages.util.PackageUtils; 097import ca.uhn.fhir.jpa.partition.IPartitionLookupSvc; 098import ca.uhn.fhir.jpa.partition.IRequestPartitionHelperSvc; 099import ca.uhn.fhir.jpa.partition.PartitionLookupSvcImpl; 100import ca.uhn.fhir.jpa.partition.PartitionManagementProvider; 101import ca.uhn.fhir.jpa.partition.RequestPartitionHelperSvc; 102import ca.uhn.fhir.jpa.provider.DiffProvider; 103import ca.uhn.fhir.jpa.provider.IReplaceReferencesSvc; 104import ca.uhn.fhir.jpa.provider.InstanceReindexProvider; 105import ca.uhn.fhir.jpa.provider.ProcessMessageProvider; 106import ca.uhn.fhir.jpa.provider.ReplaceReferencesSvcImpl; 107import ca.uhn.fhir.jpa.provider.SubscriptionTriggeringProvider; 108import ca.uhn.fhir.jpa.provider.TerminologyUploaderProvider; 109import ca.uhn.fhir.jpa.provider.ValueSetOperationProvider; 110import ca.uhn.fhir.jpa.provider.ValueSetOperationProviderDstu2; 111import ca.uhn.fhir.jpa.sched.AutowiringSpringBeanJobFactory; 112import ca.uhn.fhir.jpa.sched.HapiSchedulerServiceImpl; 113import ca.uhn.fhir.jpa.search.ISynchronousSearchSvc; 114import ca.uhn.fhir.jpa.search.PersistedJpaBundleProvider; 115import ca.uhn.fhir.jpa.search.PersistedJpaBundleProviderFactory; 116import ca.uhn.fhir.jpa.search.PersistedJpaSearchFirstPageBundleProvider; 117import ca.uhn.fhir.jpa.search.ResourceSearchUrlSvc; 118import ca.uhn.fhir.jpa.search.SearchStrategyFactory; 119import ca.uhn.fhir.jpa.search.SearchUrlJobMaintenanceSvcImpl; 120import ca.uhn.fhir.jpa.search.SynchronousSearchSvcImpl; 121import ca.uhn.fhir.jpa.search.builder.QueryStack; 122import ca.uhn.fhir.jpa.search.builder.predicate.ComboNonUniqueSearchParameterPredicateBuilder; 123import ca.uhn.fhir.jpa.search.builder.predicate.ComboUniqueSearchParameterPredicateBuilder; 124import ca.uhn.fhir.jpa.search.builder.predicate.CoordsPredicateBuilder; 125import ca.uhn.fhir.jpa.search.builder.predicate.DatePredicateBuilder; 126import ca.uhn.fhir.jpa.search.builder.predicate.NumberPredicateBuilder; 127import ca.uhn.fhir.jpa.search.builder.predicate.QuantityNormalizedPredicateBuilder; 128import ca.uhn.fhir.jpa.search.builder.predicate.QuantityPredicateBuilder; 129import ca.uhn.fhir.jpa.search.builder.predicate.ResourceHistoryPredicateBuilder; 130import ca.uhn.fhir.jpa.search.builder.predicate.ResourceHistoryProvenancePredicateBuilder; 131import ca.uhn.fhir.jpa.search.builder.predicate.ResourceIdPredicateBuilder; 132import ca.uhn.fhir.jpa.search.builder.predicate.ResourceLinkPredicateBuilder; 133import ca.uhn.fhir.jpa.search.builder.predicate.ResourceTablePredicateBuilder; 134import ca.uhn.fhir.jpa.search.builder.predicate.SearchParamPresentPredicateBuilder; 135import ca.uhn.fhir.jpa.search.builder.predicate.StringPredicateBuilder; 136import ca.uhn.fhir.jpa.search.builder.predicate.TagPredicateBuilder; 137import ca.uhn.fhir.jpa.search.builder.predicate.TokenPredicateBuilder; 138import ca.uhn.fhir.jpa.search.builder.predicate.UriPredicateBuilder; 139import ca.uhn.fhir.jpa.search.builder.sql.GeneratedSql; 140import ca.uhn.fhir.jpa.search.builder.sql.SearchQueryBuilder; 141import ca.uhn.fhir.jpa.search.builder.sql.SearchQueryExecutor; 142import ca.uhn.fhir.jpa.search.builder.sql.SqlObjectFactory; 143import ca.uhn.fhir.jpa.search.builder.tasks.SearchTask; 144import ca.uhn.fhir.jpa.search.cache.DatabaseSearchCacheSvcImpl; 145import ca.uhn.fhir.jpa.search.cache.DatabaseSearchResultCacheSvcImpl; 146import ca.uhn.fhir.jpa.search.cache.ISearchCacheSvc; 147import ca.uhn.fhir.jpa.search.cache.ISearchResultCacheSvc; 148import ca.uhn.fhir.jpa.search.elastic.IndexNamePrefixLayoutStrategy; 149import ca.uhn.fhir.jpa.search.reindex.IInstanceReindexService; 150import ca.uhn.fhir.jpa.search.reindex.IResourceReindexingSvc; 151import ca.uhn.fhir.jpa.search.reindex.InstanceReindexServiceImpl; 152import ca.uhn.fhir.jpa.search.reindex.ResourceReindexer; 153import ca.uhn.fhir.jpa.search.reindex.ResourceReindexingSvcImpl; 154import ca.uhn.fhir.jpa.search.warm.CacheWarmingSvcImpl; 155import ca.uhn.fhir.jpa.search.warm.ICacheWarmingSvc; 156import ca.uhn.fhir.jpa.searchparam.MatchUrlService; 157import ca.uhn.fhir.jpa.searchparam.config.SearchParamConfig; 158import ca.uhn.fhir.jpa.searchparam.extractor.IResourceLinkResolver; 159import ca.uhn.fhir.jpa.searchparam.registry.ISearchParamProvider; 160import ca.uhn.fhir.jpa.sp.ISearchParamPresenceSvc; 161import ca.uhn.fhir.jpa.sp.SearchParamPresenceSvcImpl; 162import ca.uhn.fhir.jpa.subscription.ResourceModifiedMessagePersistenceSvcImpl; 163import ca.uhn.fhir.jpa.term.TermCodeSystemStorageSvcImpl; 164import ca.uhn.fhir.jpa.term.TermConceptMappingSvcImpl; 165import ca.uhn.fhir.jpa.term.TermReadSvcImpl; 166import ca.uhn.fhir.jpa.term.TermReindexingSvcImpl; 167import ca.uhn.fhir.jpa.term.ValueSetConceptAccumulator; 168import ca.uhn.fhir.jpa.term.ValueSetConceptAccumulatorFactory; 169import ca.uhn.fhir.jpa.term.api.ITermCodeSystemStorageSvc; 170import ca.uhn.fhir.jpa.term.api.ITermConceptMappingSvc; 171import ca.uhn.fhir.jpa.term.api.ITermReadSvc; 172import ca.uhn.fhir.jpa.term.api.ITermReindexingSvc; 173import ca.uhn.fhir.jpa.term.config.TermCodeSystemConfig; 174import ca.uhn.fhir.jpa.util.JpaHapiTransactionService; 175import ca.uhn.fhir.jpa.util.MemoryCacheService; 176import ca.uhn.fhir.jpa.util.PartitionedIdModeVerificationSvc; 177import ca.uhn.fhir.jpa.util.PersistenceContextProvider; 178import ca.uhn.fhir.jpa.validation.JpaValidationSupportChain; 179import ca.uhn.fhir.jpa.validation.ResourceLoaderImpl; 180import ca.uhn.fhir.jpa.validation.ValidationSettings; 181import ca.uhn.fhir.model.api.IPrimitiveDatatype; 182import ca.uhn.fhir.replacereferences.ReplaceReferencesPatchBundleSvc; 183import ca.uhn.fhir.rest.api.server.RequestDetails; 184import ca.uhn.fhir.rest.api.server.storage.IDeleteExpungeJobSubmitter; 185import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; 186import ca.uhn.fhir.rest.server.interceptor.ResponseTerminologyTranslationInterceptor; 187import ca.uhn.fhir.rest.server.interceptor.ResponseTerminologyTranslationSvc; 188import ca.uhn.fhir.rest.server.interceptor.consent.IConsentContextServices; 189import ca.uhn.fhir.rest.server.interceptor.partition.RequestTenantPartitionInterceptor; 190import ca.uhn.fhir.rest.server.util.ISearchParamRegistry; 191import ca.uhn.fhir.subscription.api.IResourceModifiedMessagePersistenceSvc; 192import ca.uhn.fhir.util.IMetaTagSorter; 193import ca.uhn.fhir.util.MetaTagSorterAlphabetical; 194import ca.uhn.hapi.converters.canonical.VersionCanonicalizer; 195import jakarta.annotation.Nullable; 196import org.hl7.fhir.common.hapi.validation.support.UnknownCodeSystemWarningValidationSupport; 197import org.hl7.fhir.common.hapi.validation.support.ValidationSupportChain; 198import org.hl7.fhir.utilities.graphql.IGraphQLStorageServices; 199import org.springframework.beans.factory.annotation.Autowired; 200import org.springframework.context.annotation.Bean; 201import org.springframework.context.annotation.Configuration; 202import org.springframework.context.annotation.Import; 203import org.springframework.context.annotation.Lazy; 204import org.springframework.context.annotation.Primary; 205import org.springframework.context.annotation.Scope; 206import org.springframework.core.task.AsyncTaskExecutor; 207import org.springframework.data.envers.repository.support.EnversRevisionRepositoryFactoryBean; 208import org.springframework.data.jpa.repository.config.EnableJpaRepositories; 209import org.springframework.scheduling.TaskScheduler; 210import org.springframework.scheduling.concurrent.ConcurrentTaskScheduler; 211import org.springframework.scheduling.concurrent.ScheduledExecutorFactoryBean; 212import org.springframework.transaction.PlatformTransactionManager; 213 214import java.util.Date; 215 216@Configuration 217// repositoryFactoryBeanClass: EnversRevisionRepositoryFactoryBean is needed primarily for unit testing 218@EnableJpaRepositories( 219 basePackages = "ca.uhn.fhir.jpa.dao.data", 220 repositoryFactoryBeanClass = EnversRevisionRepositoryFactoryBean.class) 221@Import({ 222 BeanPostProcessorConfig.class, 223 TermCodeSystemConfig.class, 224 SearchParamConfig.class, 225 ValidationSupportConfig.class, 226 Batch2SupportConfig.class, 227 JpaBulkExportConfig.class, 228 SearchConfig.class, 229 PackageLoaderConfig.class, 230 EnversAuditConfig.class, 231 MdmJpaConfig.class 232}) 233public class JpaConfig { 234 public static final String JPA_VALIDATION_SUPPORT_CHAIN = "myJpaValidationSupportChain"; 235 public static final String JPA_VALIDATION_SUPPORT = "myJpaValidationSupport"; 236 public static final String TASK_EXECUTOR_NAME = "hapiJpaTaskExecutor"; 237 public static final String GRAPHQL_PROVIDER_NAME = "myGraphQLProvider"; 238 public static final String PERSISTED_JPA_BUNDLE_PROVIDER = "PersistedJpaBundleProvider"; 239 public static final String PERSISTED_JPA_BUNDLE_PROVIDER_BY_SEARCH = "PersistedJpaBundleProvider_BySearch"; 240 public static final String PERSISTED_JPA_SEARCH_FIRST_PAGE_BUNDLE_PROVIDER = 241 "PersistedJpaSearchFirstPageBundleProvider"; 242 public static final String HISTORY_BUILDER = "HistoryBuilder"; 243 public static final String DEFAULT_PROFILE_VALIDATION_SUPPORT = "myDefaultProfileValidationSupport"; 244 private static final String HAPI_DEFAULT_SCHEDULER_GROUP = "HAPI"; 245 246 @Autowired 247 public JpaStorageSettings myStorageSettings; 248 249 @Autowired 250 private FhirContext myFhirContext; 251 252 @Bean 253 public ValidationSupportChain.CacheConfiguration validationSupportChainCacheConfiguration() { 254 return ValidationSupportChain.CacheConfiguration.defaultValues(); 255 } 256 257 @Bean(name = JpaConfig.JPA_VALIDATION_SUPPORT_CHAIN) 258 @Primary 259 public IValidationSupport jpaValidationSupportChain() { 260 return new JpaValidationSupportChain(myFhirContext, validationSupportChainCacheConfiguration()); 261 } 262 263 @Bean("myDaoRegistry") 264 public DaoRegistry daoRegistry() { 265 return new DaoRegistry(); 266 } 267 268 @Lazy 269 @Bean 270 public CascadingDeleteInterceptor cascadingDeleteInterceptor( 271 FhirContext theFhirContext, 272 DaoRegistry theDaoRegistry, 273 IInterceptorBroadcaster theInterceptorBroadcaster, 274 ThreadSafeResourceDeleterSvc threadSafeResourceDeleterSvc) { 275 return new CascadingDeleteInterceptor( 276 theFhirContext, theDaoRegistry, theInterceptorBroadcaster, threadSafeResourceDeleterSvc); 277 } 278 279 @Bean 280 public ExternallyStoredResourceServiceRegistry ExternallyStoredResourceServiceRegistry() { 281 return new ExternallyStoredResourceServiceRegistry(); 282 } 283 284 @Lazy 285 @Bean 286 public ThreadSafeResourceDeleterSvc safeDeleter( 287 DaoRegistry theDaoRegistry, 288 IInterceptorBroadcaster theInterceptorBroadcaster, 289 HapiTransactionService hapiTransactionService) { 290 return new ThreadSafeResourceDeleterSvc(theDaoRegistry, theInterceptorBroadcaster, hapiTransactionService); 291 } 292 293 @Lazy 294 @Bean 295 public ResponseTerminologyTranslationInterceptor responseTerminologyTranslationInterceptor( 296 IValidationSupport theValidationSupport, 297 ResponseTerminologyTranslationSvc theResponseTerminologyTranslationSvc) { 298 return new ResponseTerminologyTranslationInterceptor( 299 theValidationSupport, theResponseTerminologyTranslationSvc); 300 } 301 302 @Bean 303 public ResponseTerminologyTranslationSvc responseTerminologyTranslationSvc( 304 IValidationSupport theValidationSupport) { 305 return new ResponseTerminologyTranslationSvc(theValidationSupport); 306 } 307 308 @Bean 309 @Lazy 310 public IGraphQLStorageServices graphqlStorageServices() { 311 return new DaoRegistryGraphQLStorageServices(); 312 } 313 314 @Bean 315 public ScheduledExecutorFactoryBean scheduledExecutorService() { 316 ScheduledExecutorFactoryBean b = new ScheduledExecutorFactoryBean(); 317 b.setPoolSize(5); 318 b.afterPropertiesSet(); 319 return b; 320 } 321 322 @Bean(name = "mySubscriptionTriggeringProvider") 323 @Lazy 324 public SubscriptionTriggeringProvider subscriptionTriggeringProvider() { 325 return new SubscriptionTriggeringProvider(); 326 } 327 328 @Bean 329 @Lazy 330 public ValueSetOperationProvider valueSetOperationProvider(FhirContext theFhirContext) { 331 if (theFhirContext.getVersion().getVersion().equals(FhirVersionEnum.DSTU2)) { 332 return new ValueSetOperationProviderDstu2(); 333 } 334 return new ValueSetOperationProvider(); 335 } 336 337 @Bean 338 public IJpaStorageResourceParser jpaStorageResourceParser() { 339 return new JpaStorageResourceParser(); 340 } 341 342 @Bean 343 public TransactionProcessor transactionProcessor() { 344 return new TransactionProcessor(); 345 } 346 347 @Bean(name = "myAttachmentBinaryAccessProvider") 348 @Lazy 349 public BinaryAccessProvider binaryAccessProvider() { 350 return new BinaryAccessProvider(); 351 } 352 353 @Bean(name = "myBinaryStorageInterceptor") 354 @Lazy 355 public BinaryStorageInterceptor<? extends IPrimitiveDatatype<byte[]>> binaryStorageInterceptor( 356 JpaStorageSettings theStorageSettings, FhirContext theCtx) { 357 BinaryStorageInterceptor<? extends IPrimitiveDatatype<byte[]>> interceptor = 358 new BinaryStorageInterceptor<>(theCtx); 359 interceptor.setAllowAutoInflateBinaries(theStorageSettings.isAllowAutoInflateBinaries()); 360 interceptor.setAutoInflateBinariesMaximumSize(theStorageSettings.getAutoInflateBinariesMaximumBytes()); 361 return interceptor; 362 } 363 364 @Bean 365 public MemoryCacheService memoryCacheService(JpaStorageSettings theStorageSettings) { 366 return new MemoryCacheService(theStorageSettings); 367 } 368 369 @Bean 370 @Primary 371 public IResourceLinkResolver daoResourceLinkResolver() { 372 return new DaoResourceLinkResolver<JpaPid>(); 373 } 374 375 @Bean(name = PackageUtils.LOADER_WITH_CACHE) 376 public IHapiPackageCacheManager packageCacheManager() { 377 return new JpaPackageCache(); 378 } 379 380 @Bean 381 public NpmJpaValidationSupport npmJpaValidationSupport() { 382 return new NpmJpaValidationSupport(); 383 } 384 385 @Bean 386 public ValidationSettings validationSettings() { 387 return new ValidationSettings(); 388 } 389 390 @Bean 391 public ISearchCacheSvc searchCacheSvc() { 392 return new DatabaseSearchCacheSvcImpl(); 393 } 394 395 @Bean 396 public ISearchResultCacheSvc searchResultCacheSvc() { 397 return new DatabaseSearchResultCacheSvcImpl(); 398 } 399 400 @Bean 401 public ITermConceptMappingSvc termConceptMappingSvc() { 402 return new TermConceptMappingSvcImpl(); 403 } 404 405 @Bean 406 public TaskScheduler taskScheduler() { 407 ConcurrentTaskScheduler retVal = new ConcurrentTaskScheduler( 408 scheduledExecutorService().getObject(), 409 scheduledExecutorService().getObject()); 410 return retVal; 411 } 412 413 @Bean(name = TASK_EXECUTOR_NAME) 414 public AsyncTaskExecutor taskExecutor() { 415 ConcurrentTaskScheduler retVal = new ConcurrentTaskScheduler( 416 scheduledExecutorService().getObject(), 417 scheduledExecutorService().getObject()); 418 return retVal; 419 } 420 421 @Bean 422 public IResourceReindexingSvc resourceReindexingSvc() { 423 return new ResourceReindexingSvcImpl(); 424 } 425 426 @Bean 427 @Lazy 428 public IInstanceReindexService instanceReindexService() { 429 return new InstanceReindexServiceImpl(); 430 } 431 432 @Bean 433 @Lazy 434 public InstanceReindexProvider instanceReindexProvider(IInstanceReindexService theInstanceReindexService) { 435 return new InstanceReindexProvider(theInstanceReindexService); 436 } 437 438 @Bean 439 public ResourceReindexer resourceReindexer(FhirContext theFhirContext) { 440 return new ResourceReindexer(theFhirContext); 441 } 442 443 @Bean 444 public HapiFhirHibernateJpaDialect hibernateJpaDialect(FhirContext theFhirContext) { 445 return new HapiFhirHibernateJpaDialect(theFhirContext.getLocalizer()); 446 } 447 448 @Bean 449 @Lazy 450 public OverridePathBasedReferentialIntegrityForDeletesInterceptor 451 overridePathBasedReferentialIntegrityForDeletesInterceptor() { 452 return new OverridePathBasedReferentialIntegrityForDeletesInterceptor(); 453 } 454 455 @Bean 456 public IRequestPartitionHelperSvc requestPartitionHelperService() { 457 return new RequestPartitionHelperSvc(); 458 } 459 460 @Bean 461 public HapiTransactionService hapiTransactionService() { 462 return new JpaHapiTransactionService(); 463 } 464 465 @Bean 466 public IInterceptorService jpaInterceptorService() { 467 return new InterceptorService("JPA"); 468 } 469 470 @Bean 471 public IPackageInstallerSvc npmInstallerSvc() { 472 return new PackageInstallerSvcImpl(); 473 } 474 475 @Bean 476 public IConsentContextServices consentContextServices() { 477 return new JpaConsentContextServices(); 478 } 479 480 @Bean 481 @Lazy 482 public DiffProvider diffProvider() { 483 return new DiffProvider(); 484 } 485 486 @Bean 487 @Lazy 488 public IPartitionLookupSvc partitionConfigSvc() { 489 return new PartitionLookupSvcImpl(); 490 } 491 492 @Bean 493 @Lazy 494 public PartitionManagementProvider partitionManagementProvider() { 495 return new PartitionManagementProvider(); 496 } 497 498 @Bean 499 @Lazy 500 public RequestTenantPartitionInterceptor requestTenantPartitionInterceptor() { 501 return new RequestTenantPartitionInterceptor(); 502 } 503 504 @Bean 505 @Lazy 506 public TerminologyUploaderProvider terminologyUploaderProvider() { 507 return new TerminologyUploaderProvider(); 508 } 509 510 @Bean 511 @Lazy 512 public ProcessMessageProvider processMessageProvider() { 513 return new ProcessMessageProvider(); 514 } 515 516 @Bean 517 public ISchedulerService schedulerService() { 518 return new HapiSchedulerServiceImpl().setDefaultGroup(HAPI_DEFAULT_SCHEDULER_GROUP); 519 } 520 521 @Bean 522 public AutowiringSpringBeanJobFactory schedulerJobFactory() { 523 return new AutowiringSpringBeanJobFactory(); 524 } 525 526 @Bean 527 public IBulkDataExportJobSchedulingHelper bulkDataExportJobSchedulingHelper( 528 DaoRegistry theDaoRegistry, 529 PlatformTransactionManager theTxManager, 530 JpaStorageSettings theStorageSettings, 531 BulkExportHelperService theBulkExportHelperSvc, 532 IJobPersistence theJpaJobPersistence) { 533 return new BulkDataExportJobSchedulingHelperImpl( 534 theDaoRegistry, theTxManager, theStorageSettings, theBulkExportHelperSvc, theJpaJobPersistence, null); 535 } 536 537 @Bean 538 @Lazy 539 public BulkDataExportProvider bulkDataExportProvider() { 540 return new BulkDataExportProvider(); 541 } 542 543 @Bean 544 @Lazy 545 public IDeleteExpungeJobSubmitter deleteExpungeJobSubmitter() { 546 return new DeleteExpungeJobSubmitterImpl(); 547 } 548 549 @Bean 550 @Lazy 551 public IBulkDataImportSvc bulkDataImportSvc() { 552 return new BulkDataImportSvcImpl(); 553 } 554 555 @Bean 556 public PersistedJpaBundleProviderFactory persistedJpaBundleProviderFactory() { 557 return new PersistedJpaBundleProviderFactory(); 558 } 559 560 @Bean 561 public SearchBuilderFactory searchBuilderFactory() { 562 return new SearchBuilderFactory(); 563 } 564 565 @Bean 566 public SqlObjectFactory sqlBuilderFactory() { 567 return new SqlObjectFactory(); 568 } 569 570 @Bean 571 public HibernatePropertiesProvider HibernatePropertiesProvider() { 572 return new HibernatePropertiesProvider(); 573 } 574 575 @Bean 576 public HistoryBuilderFactory historyBuilderFactory() { 577 return new HistoryBuilderFactory(); 578 } 579 580 @Bean 581 public IResourceVersionSvc resourceVersionSvc() { 582 return new ResourceVersionSvcDaoImpl(); 583 } 584 585 /* **************************************************************** * 586 * Prototype Beans Below * 587 * **************************************************************** */ 588 589 @Bean(name = PERSISTED_JPA_BUNDLE_PROVIDER) 590 @Scope("prototype") 591 public PersistedJpaBundleProvider newPersistedJpaBundleProvider(RequestDetails theRequest, String theUuid) { 592 return new PersistedJpaBundleProvider(theRequest, theUuid); 593 } 594 595 @Bean(name = PERSISTED_JPA_BUNDLE_PROVIDER_BY_SEARCH) 596 @Scope("prototype") 597 public PersistedJpaBundleProvider newPersistedJpaBundleProviderBySearch( 598 RequestDetails theRequest, Search theSearch) { 599 return new PersistedJpaBundleProvider(theRequest, theSearch); 600 } 601 602 @Bean(name = PERSISTED_JPA_SEARCH_FIRST_PAGE_BUNDLE_PROVIDER) 603 @Scope("prototype") 604 public PersistedJpaSearchFirstPageBundleProvider newPersistedJpaSearchFirstPageBundleProvider( 605 RequestDetails theRequest, 606 SearchTask theSearchTask, 607 ISearchBuilder theSearchBuilder, 608 RequestPartitionId theRequestPartitionId) { 609 return new PersistedJpaSearchFirstPageBundleProvider( 610 theSearchTask, theSearchBuilder, theRequest, theRequestPartitionId); 611 } 612 613 @Bean(name = RepositoryValidatingRuleBuilder.REPOSITORY_VALIDATING_RULE_BUILDER) 614 @Scope("prototype") 615 public RepositoryValidatingRuleBuilder repositoryValidatingRuleBuilder(IValidationSupport theValidationSupport) { 616 return new RepositoryValidatingRuleBuilder(theValidationSupport); 617 } 618 619 @Bean 620 @Scope("prototype") 621 public ComboUniqueSearchParameterPredicateBuilder newComboUniqueSearchParameterPredicateBuilder( 622 SearchQueryBuilder theSearchSqlBuilder) { 623 return new ComboUniqueSearchParameterPredicateBuilder(theSearchSqlBuilder); 624 } 625 626 @Bean 627 @Scope("prototype") 628 public ComboNonUniqueSearchParameterPredicateBuilder newComboNonUniqueSearchParameterPredicateBuilder( 629 SearchQueryBuilder theSearchSqlBuilder) { 630 return new ComboNonUniqueSearchParameterPredicateBuilder(theSearchSqlBuilder); 631 } 632 633 @Bean 634 @Scope("prototype") 635 public CoordsPredicateBuilder newCoordsPredicateBuilder(SearchQueryBuilder theSearchBuilder) { 636 return new CoordsPredicateBuilder(theSearchBuilder); 637 } 638 639 @Bean 640 @Scope("prototype") 641 public DatePredicateBuilder newDatePredicateBuilder(SearchQueryBuilder theSearchBuilder) { 642 return new DatePredicateBuilder(theSearchBuilder); 643 } 644 645 @Bean 646 @Scope("prototype") 647 public NumberPredicateBuilder newNumberPredicateBuilder(SearchQueryBuilder theSearchBuilder) { 648 return new NumberPredicateBuilder(theSearchBuilder); 649 } 650 651 @Bean 652 @Scope("prototype") 653 public QuantityPredicateBuilder newQuantityPredicateBuilder(SearchQueryBuilder theSearchBuilder) { 654 return new QuantityPredicateBuilder(theSearchBuilder); 655 } 656 657 @Bean 658 @Scope("prototype") 659 public QuantityNormalizedPredicateBuilder newQuantityNormalizedPredicateBuilder( 660 SearchQueryBuilder theSearchBuilder) { 661 return new QuantityNormalizedPredicateBuilder(theSearchBuilder); 662 } 663 664 @Bean 665 @Scope("prototype") 666 public ResourceLinkPredicateBuilder newResourceLinkPredicateBuilder( 667 QueryStack theQueryStack, SearchQueryBuilder theSearchBuilder, boolean theReversed) { 668 return new ResourceLinkPredicateBuilder(theQueryStack, theSearchBuilder, theReversed); 669 } 670 671 @Bean 672 @Scope("prototype") 673 public ResourceTablePredicateBuilder newResourceTablePredicateBuilder(SearchQueryBuilder theSearchBuilder) { 674 return new ResourceTablePredicateBuilder(theSearchBuilder); 675 } 676 677 @Bean 678 @Scope("prototype") 679 public TagPredicateBuilder newTagPredicateBuilder(SearchQueryBuilder theSearchBuilder) { 680 return new TagPredicateBuilder(theSearchBuilder); 681 } 682 683 @Bean 684 @Scope("prototype") 685 public ResourceIdPredicateBuilder newResourceIdPredicateBuilder(SearchQueryBuilder theSearchBuilder) { 686 return new ResourceIdPredicateBuilder(theSearchBuilder); 687 } 688 689 @Bean 690 @Scope("prototype") 691 public SearchParamPresentPredicateBuilder newSearchParamPresentPredicateBuilder( 692 SearchQueryBuilder theSearchBuilder) { 693 return new SearchParamPresentPredicateBuilder(theSearchBuilder); 694 } 695 696 @Bean 697 @Scope("prototype") 698 public StringPredicateBuilder newStringPredicateBuilder(SearchQueryBuilder theSearchBuilder) { 699 return new StringPredicateBuilder(theSearchBuilder); 700 } 701 702 @Bean 703 @Scope("prototype") 704 public TokenPredicateBuilder newTokenPredicateBuilder(SearchQueryBuilder theSearchBuilder) { 705 return new TokenPredicateBuilder(theSearchBuilder); 706 } 707 708 @Bean 709 @Scope("prototype") 710 public ResourceHistoryPredicateBuilder newResourceHistoryPredicateBuilder(SearchQueryBuilder theSearchBuilder) { 711 return new ResourceHistoryPredicateBuilder(theSearchBuilder); 712 } 713 714 @Bean 715 @Scope("prototype") 716 public ResourceHistoryProvenancePredicateBuilder newResourceHistoryProvenancePredicateBuilder( 717 SearchQueryBuilder theSearchBuilder) { 718 return new ResourceHistoryProvenancePredicateBuilder(theSearchBuilder); 719 } 720 721 @Bean 722 @Scope("prototype") 723 public UriPredicateBuilder newUriPredicateBuilder(SearchQueryBuilder theSearchBuilder) { 724 return new UriPredicateBuilder(theSearchBuilder); 725 } 726 727 @Bean 728 @Scope("prototype") 729 public SearchQueryExecutor newSearchQueryExecutor(GeneratedSql theGeneratedSql, Integer theMaxResultsToFetch) { 730 return new SearchQueryExecutor(theGeneratedSql, theMaxResultsToFetch); 731 } 732 733 @Bean(name = HISTORY_BUILDER) 734 @Scope("prototype") 735 public HistoryBuilder newHistoryBuilder( 736 @Nullable String theResourceType, 737 @Nullable JpaPid theResourceId, 738 @Nullable Date theRangeStartInclusive, 739 @Nullable Date theRangeEndInclusive) { 740 return new HistoryBuilder(theResourceType, theResourceId, theRangeStartInclusive, theRangeEndInclusive); 741 } 742 743 @Bean 744 @Primary 745 public ISearchParamProvider searchParamProvider() { 746 return new DaoSearchParamProvider(); 747 } 748 749 @Bean 750 public IIdHelperService idHelperService() { 751 return new IdHelperService(); 752 } 753 754 @Bean 755 public SearchStrategyFactory searchStrategyFactory(@Autowired(required = false) IFulltextSearchSvc theFulltextSvc) { 756 return new SearchStrategyFactory(myStorageSettings, theFulltextSvc); 757 } 758 759 @Bean 760 public DeleteConflictService deleteConflictService() { 761 return new DeleteConflictService(); 762 } 763 764 @Bean 765 public DeleteConflictFinderService deleteConflictFinderService() { 766 return new DeleteConflictFinderService(); 767 } 768 769 @Bean 770 public ExpungeService expungeService() { 771 return new ExpungeService(); 772 } 773 774 @Bean 775 @Scope("prototype") 776 public ExpungeOperation expungeOperation( 777 String theResourceName, 778 IResourcePersistentId theResourceId, 779 ExpungeOptions theExpungeOptions, 780 RequestDetails theRequestDetails) { 781 return new ExpungeOperation(theResourceName, theResourceId, theExpungeOptions, theRequestDetails); 782 } 783 784 @Bean 785 public IExpungeEverythingService expungeEverythingService() { 786 return new ExpungeEverythingService(); 787 } 788 789 @Bean 790 public IResourceExpungeService resourceExpungeService() { 791 return new JpaResourceExpungeService(); 792 } 793 794 @Bean 795 public ISearchParamPresenceSvc searchParamPresenceService() { 796 return new SearchParamPresenceSvcImpl(); 797 } 798 799 @Bean 800 public SearchParamWithInlineReferencesExtractor searchParamWithInlineReferencesExtractor() { 801 return new SearchParamWithInlineReferencesExtractor(); 802 } 803 804 @Bean 805 public MatchResourceUrlService matchResourceUrlService() { 806 return new MatchResourceUrlService(); 807 } 808 809 @Bean 810 public DaoSearchParamSynchronizer daoSearchParamSynchronizer() { 811 return new DaoSearchParamSynchronizer(); 812 } 813 814 @Bean 815 public ResourceTableFKProvider resourceTableFKProvider() { 816 return new ResourceTableFKProvider(); 817 } 818 819 @Bean 820 public ICacheWarmingSvc cacheWarmingSvc() { 821 return new CacheWarmingSvcImpl(); 822 } 823 824 @Bean 825 public IndexNamePrefixLayoutStrategy indexLayoutStrategy() { 826 return new IndexNamePrefixLayoutStrategy(); 827 } 828 829 @Bean 830 public ResourceLoaderImpl jpaResourceLoader() { 831 return new ResourceLoaderImpl(); 832 } 833 834 @Bean 835 public UnknownCodeSystemWarningValidationSupport unknownCodeSystemWarningValidationSupport( 836 FhirContext theFhirContext) { 837 return new UnknownCodeSystemWarningValidationSupport(theFhirContext); 838 } 839 840 @Bean 841 public ISynchronousSearchSvc synchronousSearchSvc() { 842 return new SynchronousSearchSvcImpl(); 843 } 844 845 @Bean 846 public VersionCanonicalizer versionCanonicalizer(FhirContext theFhirContext) { 847 return new VersionCanonicalizer(theFhirContext); 848 } 849 850 @Bean 851 public SearchParameterDaoValidator searchParameterDaoValidator( 852 FhirContext theFhirContext, 853 JpaStorageSettings theStorageSettings, 854 ISearchParamRegistry theSearchParamRegistry) { 855 return new SearchParameterDaoValidator(theFhirContext, theStorageSettings, theSearchParamRegistry); 856 } 857 858 @Bean 859 public ITermReadSvc terminologyService() { 860 return new TermReadSvcImpl(); 861 } 862 863 @Bean 864 public ValueSetConceptAccumulatorFactory valueSetConceptAccumulatorFactory() { 865 return new ValueSetConceptAccumulatorFactory(); 866 } 867 868 @Bean 869 @Scope("prototype") 870 public ValueSetConceptAccumulator valueSetConceptAccumulator(TermValueSet theTermValueSet) { 871 return valueSetConceptAccumulatorFactory().create(theTermValueSet); 872 } 873 874 @Bean 875 public ITermCodeSystemStorageSvc termCodeSystemStorageSvc() { 876 return new TermCodeSystemStorageSvcImpl(); 877 } 878 879 @Bean 880 public ITermReindexingSvc termReindexingSvc() { 881 return new TermReindexingSvcImpl(); 882 } 883 884 @Bean 885 @Scope("prototype") 886 public PersistenceContextProvider persistenceContextProvider() { 887 return new PersistenceContextProvider(); 888 } 889 890 @Bean 891 public ResourceSearchUrlSvc resourceSearchUrlSvc( 892 PersistenceContextProvider thePersistenceContextProvider, 893 IResourceSearchUrlDao theResourceSearchUrlDao, 894 MatchUrlService theMatchUrlService, 895 FhirContext theFhirContext, 896 PartitionSettings thePartitionSettings) { 897 return new ResourceSearchUrlSvc( 898 thePersistenceContextProvider.getEntityManager(), 899 theResourceSearchUrlDao, 900 theMatchUrlService, 901 theFhirContext, 902 thePartitionSettings); 903 } 904 905 @Bean 906 public ISearchUrlJobMaintenanceSvc searchUrlJobMaintenanceSvc(ResourceSearchUrlSvc theResourceSearchUrlSvc) { 907 return new SearchUrlJobMaintenanceSvcImpl(theResourceSearchUrlSvc); 908 } 909 910 @Bean 911 public IResourceModifiedMessagePersistenceSvc subscriptionMessagePersistence( 912 FhirContext theFhirContext, 913 IResourceModifiedDao theIResourceModifiedDao, 914 DaoRegistry theDaoRegistry, 915 HapiTransactionService theHapiTransactionService) { 916 return new ResourceModifiedMessagePersistenceSvcImpl( 917 theFhirContext, theIResourceModifiedDao, theDaoRegistry, theHapiTransactionService); 918 } 919 920 @Bean 921 public IMetaTagSorter metaTagSorter() { 922 return new MetaTagSorterAlphabetical(); 923 } 924 925 @Bean 926 public ResourceHistoryCalculator resourceHistoryCalculator( 927 FhirContext theFhirContext, HibernatePropertiesProvider theHibernatePropertiesProvider) { 928 return new ResourceHistoryCalculator(theFhirContext, theHibernatePropertiesProvider.isOracleDialect()); 929 } 930 931 @Bean 932 public CacheTagDefinitionDao tagDefinitionDao( 933 ITagDefinitionDao tagDefinitionDao, MemoryCacheService memoryCacheService) { 934 return new CacheTagDefinitionDao(tagDefinitionDao, memoryCacheService); 935 } 936 937 @Bean 938 public Batch2TaskHelper batch2TaskHelper() { 939 return new Batch2TaskHelper(); 940 } 941 942 @Bean 943 public IReplaceReferencesSvc replaceReferencesSvc( 944 DaoRegistry theDaoRegistry, 945 HapiTransactionService theHapiTransactionService, 946 IResourceLinkDao theResourceLinkDao, 947 IJobCoordinator theJobCoordinator, 948 ReplaceReferencesPatchBundleSvc theReplaceReferencesPatchBundle, 949 Batch2TaskHelper theBatch2TaskHelper, 950 JpaStorageSettings theStorageSettings) { 951 return new ReplaceReferencesSvcImpl( 952 theDaoRegistry, 953 theHapiTransactionService, 954 theResourceLinkDao, 955 theJobCoordinator, 956 theReplaceReferencesPatchBundle, 957 theBatch2TaskHelper, 958 theStorageSettings); 959 } 960 961 @Bean 962 public ReplaceReferencesPatchBundleSvc replaceReferencesPatchBundleSvc(DaoRegistry theDaoRegistry) { 963 return new ReplaceReferencesPatchBundleSvc(theDaoRegistry); 964 } 965 966 @Bean 967 public PartitionedIdModeVerificationSvc partitionedIdModeVerificationSvc( 968 PartitionSettings thePartitionSettings, 969 HibernatePropertiesProvider theHibernatePropertiesProvider, 970 PlatformTransactionManager theTxManager) { 971 return new PartitionedIdModeVerificationSvc(thePartitionSettings, theHibernatePropertiesProvider, theTxManager); 972 } 973}