001package ca.uhn.fhir.jpa.subscription.match.config;
002
003/*-
004 * #%L
005 * HAPI FHIR Subscription Server
006 * %%
007 * Copyright (C) 2014 - 2021 Smile CDR, Inc.
008 * %%
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 *
013 *      http://www.apache.org/licenses/LICENSE-2.0
014 *
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 * #L%
021 */
022
023import ca.uhn.fhir.jpa.subscription.channel.subscription.SubscriptionChannelRegistry;
024import ca.uhn.fhir.jpa.subscription.channel.subscription.SubscriptionDeliveryChannelNamer;
025import ca.uhn.fhir.jpa.subscription.channel.subscription.SubscriptionDeliveryHandlerFactory;
026import ca.uhn.fhir.jpa.subscription.match.deliver.email.IEmailSender;
027import ca.uhn.fhir.jpa.subscription.match.deliver.email.SubscriptionDeliveringEmailSubscriber;
028import ca.uhn.fhir.jpa.subscription.match.deliver.message.SubscriptionDeliveringMessageSubscriber;
029import ca.uhn.fhir.jpa.subscription.match.deliver.resthook.SubscriptionDeliveringRestHookSubscriber;
030import ca.uhn.fhir.jpa.subscription.match.matcher.matching.CompositeInMemoryDaoSubscriptionMatcher;
031import ca.uhn.fhir.jpa.subscription.match.matcher.matching.DaoSubscriptionMatcher;
032import ca.uhn.fhir.jpa.subscription.match.matcher.matching.ISubscriptionMatcher;
033import ca.uhn.fhir.jpa.subscription.match.matcher.matching.InMemorySubscriptionMatcher;
034import ca.uhn.fhir.jpa.subscription.match.matcher.subscriber.MatchingQueueSubscriberLoader;
035import ca.uhn.fhir.jpa.subscription.match.matcher.subscriber.SubscriptionActivatingSubscriber;
036import ca.uhn.fhir.jpa.subscription.match.matcher.subscriber.SubscriptionMatchingSubscriber;
037import ca.uhn.fhir.jpa.subscription.match.matcher.subscriber.SubscriptionRegisteringSubscriber;
038import ca.uhn.fhir.jpa.subscription.match.registry.SubscriptionLoader;
039import ca.uhn.fhir.jpa.subscription.match.registry.SubscriptionRegistry;
040import ca.uhn.fhir.jpa.subscription.model.config.SubscriptionModelConfig;
041import org.springframework.context.annotation.Bean;
042import org.springframework.context.annotation.Import;
043import org.springframework.context.annotation.Primary;
044import org.springframework.context.annotation.Scope;
045
046/**
047 * This Spring config should be imported by a system that pulls messages off of the
048 * matching queue for processing, and handles delivery
049 */
050@Import(SubscriptionModelConfig.class)
051public class SubscriptionProcessorConfig {
052
053        @Bean
054        public SubscriptionMatchingSubscriber subscriptionMatchingSubscriber() {
055                return new SubscriptionMatchingSubscriber();
056        }
057
058        @Bean
059        public SubscriptionActivatingSubscriber subscriptionActivatingSubscriber() {
060                return new SubscriptionActivatingSubscriber();
061        }
062
063        @Bean
064        public MatchingQueueSubscriberLoader subscriptionMatchingSubscriberLoader() {
065                return new MatchingQueueSubscriberLoader();
066        }
067
068        @Bean
069        public SubscriptionRegisteringSubscriber subscriptionRegisteringSubscriber() {
070                return new SubscriptionRegisteringSubscriber();
071        }
072
073        @Bean
074        public SubscriptionRegistry subscriptionRegistry() {
075                return new SubscriptionRegistry();
076        }
077
078        @Bean
079        public SubscriptionDeliveryChannelNamer subscriptionDeliveryChannelNamer() {
080                return new SubscriptionDeliveryChannelNamer();
081        }
082
083        @Bean
084        public SubscriptionLoader subscriptionLoader() {
085                return new SubscriptionLoader();
086        }
087
088        @Bean
089        public SubscriptionChannelRegistry subscriptionChannelRegistry() {
090                return new SubscriptionChannelRegistry();
091        }
092
093        @Bean
094        public SubscriptionDeliveryHandlerFactory subscriptionDeliveryHandlerFactory() {
095                return new SubscriptionDeliveryHandlerFactory();
096        }
097
098        @Bean
099        @Scope("prototype")
100        public SubscriptionDeliveringRestHookSubscriber subscriptionDeliveringRestHookSubscriber() {
101                return new SubscriptionDeliveringRestHookSubscriber();
102        }
103
104        @Bean
105        @Scope("prototype")
106        public SubscriptionDeliveringMessageSubscriber subscriptionDeliveringMessageSubscriber() {
107                return new SubscriptionDeliveringMessageSubscriber();
108        }
109
110        @Bean
111        @Scope("prototype")
112        public SubscriptionDeliveringEmailSubscriber subscriptionDeliveringEmailSubscriber(IEmailSender theEmailSender) {
113                return new SubscriptionDeliveringEmailSubscriber(theEmailSender);
114        }
115
116        @Bean
117        public InMemorySubscriptionMatcher inMemorySubscriptionMatcher() {
118                return new InMemorySubscriptionMatcher();
119        }
120
121        @Bean
122        public DaoSubscriptionMatcher daoSubscriptionMatcher() {
123                return new DaoSubscriptionMatcher();
124        }
125
126        @Bean
127        @Primary
128        public ISubscriptionMatcher subscriptionMatcher(DaoSubscriptionMatcher theDaoSubscriptionMatcher, InMemorySubscriptionMatcher theInMemorySubscriptionMatcher) {
129                return new CompositeInMemoryDaoSubscriptionMatcher(theDaoSubscriptionMatcher, theInMemorySubscriptionMatcher);
130        }
131
132}