001/*- 002 * #%L 003 * HAPI FHIR Subscription Server 004 * %% 005 * Copyright (C) 2014 - 2024 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.subscription.submit.config; 021 022import ca.uhn.fhir.jpa.api.dao.DaoRegistry; 023import ca.uhn.fhir.jpa.dao.tx.IHapiTransactionService; 024import ca.uhn.fhir.jpa.model.entity.StorageSettings; 025import ca.uhn.fhir.jpa.subscription.async.AsyncResourceModifiedProcessingSchedulerSvc; 026import ca.uhn.fhir.jpa.subscription.async.AsyncResourceModifiedSubmitterSvc; 027import ca.uhn.fhir.jpa.subscription.channel.subscription.SubscriptionChannelFactory; 028import ca.uhn.fhir.jpa.subscription.match.matcher.matching.SubscriptionStrategyEvaluator; 029import ca.uhn.fhir.jpa.subscription.model.config.SubscriptionModelConfig; 030import ca.uhn.fhir.jpa.subscription.submit.interceptor.SubscriptionQueryValidator; 031import ca.uhn.fhir.jpa.subscription.submit.interceptor.SubscriptionSubmitInterceptorLoader; 032import ca.uhn.fhir.jpa.subscription.submit.interceptor.SubscriptionValidatingInterceptor; 033import ca.uhn.fhir.jpa.subscription.submit.svc.ResourceModifiedSubmitterSvc; 034import ca.uhn.fhir.jpa.subscription.triggering.ISubscriptionTriggeringSvc; 035import ca.uhn.fhir.jpa.subscription.triggering.SubscriptionTriggeringSvcImpl; 036import ca.uhn.fhir.subscription.api.IResourceModifiedConsumerWithRetries; 037import ca.uhn.fhir.subscription.api.IResourceModifiedMessagePersistenceSvc; 038import org.springframework.context.annotation.Bean; 039import org.springframework.context.annotation.Configuration; 040import org.springframework.context.annotation.Import; 041import org.springframework.context.annotation.Lazy; 042 043/** 044 * This Spring config should be imported by a system that submits resources to the 045 * matching queue for processing 046 */ 047@Configuration 048@Import({SubscriptionModelConfig.class, SubscriptionMatcherInterceptorConfig.class}) 049public class SubscriptionSubmitterConfig { 050 051 @Bean 052 public SubscriptionValidatingInterceptor subscriptionValidatingInterceptor() { 053 return new SubscriptionValidatingInterceptor(); 054 } 055 056 @Bean 057 public SubscriptionQueryValidator subscriptionQueryValidator( 058 DaoRegistry theDaoRegistry, SubscriptionStrategyEvaluator theSubscriptionStrategyEvaluator) { 059 return new SubscriptionQueryValidator(theDaoRegistry, theSubscriptionStrategyEvaluator); 060 } 061 062 @Bean 063 public SubscriptionSubmitInterceptorLoader subscriptionMatcherInterceptorLoader() { 064 return new SubscriptionSubmitInterceptorLoader(); 065 } 066 067 @Bean 068 @Lazy 069 public ISubscriptionTriggeringSvc subscriptionTriggeringSvc() { 070 return new SubscriptionTriggeringSvcImpl(); 071 } 072 073 @Bean 074 public ResourceModifiedSubmitterSvc resourceModifiedSvc( 075 IHapiTransactionService theHapiTransactionService, 076 IResourceModifiedMessagePersistenceSvc theResourceModifiedMessagePersistenceSvc, 077 SubscriptionChannelFactory theSubscriptionChannelFactory, 078 StorageSettings theStorageSettings) { 079 080 return new ResourceModifiedSubmitterSvc( 081 theStorageSettings, 082 theSubscriptionChannelFactory, 083 theResourceModifiedMessagePersistenceSvc, 084 theHapiTransactionService); 085 } 086 087 @Bean 088 public AsyncResourceModifiedProcessingSchedulerSvc asyncResourceModifiedProcessingSchedulerSvc() { 089 return new AsyncResourceModifiedProcessingSchedulerSvc(); 090 } 091 092 @Bean 093 public AsyncResourceModifiedSubmitterSvc asyncResourceModifiedSubmitterSvc( 094 IResourceModifiedMessagePersistenceSvc theIResourceModifiedMessagePersistenceSvc, 095 IResourceModifiedConsumerWithRetries theResourceModifiedConsumer) { 096 return new AsyncResourceModifiedSubmitterSvc( 097 theIResourceModifiedMessagePersistenceSvc, theResourceModifiedConsumer); 098 } 099}