c00deea66e73eda5e9a2a007cba7e1a7c4104fb0
[clamp.git] / src / main / java / org / onap / clamp / clds / config / CldsConfiguration.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP CLAMP
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights
6  *                             reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License"); 
9  * you may not use this file except in compliance with the License. 
10  * You may obtain a copy of the License at
11  * 
12  * http://www.apache.org/licenses/LICENSE-2.0
13  * 
14  * Unless required by applicable law or agreed to in writing, software 
15  * distributed under the License is distributed on an "AS IS" BASIS, 
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
17  * See the License for the specific language governing permissions and 
18  * limitations under the License.
19  * ============LICENSE_END============================================
20  * ===================================================================
21  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  */
23
24 package org.onap.clamp.clds.config;
25
26 import com.att.ajsc.common.AjscProvider;
27 import com.att.ajsc.common.AjscService;
28
29 import java.util.ArrayList;
30 import java.util.List;
31
32 import javax.sql.DataSource;
33 import javax.xml.transform.TransformerConfigurationException;
34
35 import org.onap.clamp.clds.client.CldsEventDelegate;
36 import org.onap.clamp.clds.client.DcaeDispatcherServices;
37 import org.onap.clamp.clds.client.DcaeInventoryServices;
38 import org.onap.clamp.clds.client.DcaeReqDelegate;
39 import org.onap.clamp.clds.client.DcaeReqDeleteDelegate;
40 import org.onap.clamp.clds.client.HolmesPolicyDelegate;
41 import org.onap.clamp.clds.client.HolmesPolicyDeleteDelegate;
42 import org.onap.clamp.clds.client.OperationalPolicyDelegate;
43 import org.onap.clamp.clds.client.OperationalPolicyDeleteDelegate;
44 import org.onap.clamp.clds.client.PolicyClient;
45 import org.onap.clamp.clds.client.SdcCatalogServices;
46 import org.onap.clamp.clds.client.SdcSendReqDelegate;
47 import org.onap.clamp.clds.client.StringMatchPolicyDelegate;
48 import org.onap.clamp.clds.client.StringMatchPolicyDeleteDelegate;
49 import org.onap.clamp.clds.client.TcaPolicyDelegate;
50 import org.onap.clamp.clds.client.TcaPolicyDeleteDelegate;
51 import org.onap.clamp.clds.dao.CldsDao;
52 import org.onap.clamp.clds.model.refprop.RefProp;
53 import org.onap.clamp.clds.transform.XslTransformer;
54 import org.springframework.beans.factory.annotation.Autowired;
55 import org.springframework.beans.factory.annotation.Qualifier;
56 import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
57 import org.springframework.boot.context.properties.ConfigurationProperties;
58 import org.springframework.context.ApplicationContext;
59 import org.springframework.context.annotation.Bean;
60 import org.springframework.context.annotation.Configuration;
61 import org.springframework.context.annotation.Profile;
62
63 @Configuration
64 @Profile("clamp-default")
65 public class CldsConfiguration {
66
67     @Autowired
68     private ApplicationContext context;
69
70     /**
71      * Clds Identity database DataSource configuration
72      */
73     @Bean(name = "cldsDataSource")
74     @ConfigurationProperties(prefix = "spring.datasource.cldsdb")
75     public DataSource cldsDataSource() {
76         return DataSourceBuilder.create().build();
77     }
78
79     @Bean(name = "jaxrsProviders")
80     public List<?> jaxrsProviders() {
81         return new ArrayList(context.getBeansWithAnnotation(AjscProvider.class).values());
82     }
83
84     @Bean(name = "jaxrsServices")
85     public List<?> jaxrsServices() {
86         return new ArrayList(context.getBeansWithAnnotation(AjscService.class).values());
87     }
88
89     @Bean(name = "cldsDao")
90     public CldsDao getCldsDao(@Qualifier("cldsDataSource") DataSource dataSource) {
91         CldsDao cldsDao = new CldsDao();
92         cldsDao.setDataSource(dataSource);
93         return cldsDao;
94     }
95
96     @Bean(name = "cldsBpmnTransformer")
97     public XslTransformer getCldsBpmnXslTransformer() throws TransformerConfigurationException {
98         XslTransformer xslTransformer = new XslTransformer();
99         xslTransformer.setXslResourceName("xsl/clds-bpmn-transformer.xsl");
100         return xslTransformer;
101     }
102
103     @Bean
104     public RefProp getRefProp() {
105         return new RefProp();
106     }
107
108     @Bean
109     public PolicyClient getPolicyClient() {
110         return new PolicyClient();
111     }
112
113     @Bean(name = "cldsEventDelegate")
114     public CldsEventDelegate getCldsEventDelegate() {
115         return new CldsEventDelegate();
116     }
117
118     @Bean(name = "dcaeReqDelegate")
119     public DcaeReqDelegate getDcaeReqDelegate() {
120         return new DcaeReqDelegate();
121     }
122
123     @Bean(name = "sdcSendReqDelegate")
124     public SdcSendReqDelegate getSdcSendReqDelegate() {
125         return new SdcSendReqDelegate();
126     }
127
128     @Bean(name = "dcaeReqDeleteDelegate")
129     public DcaeReqDeleteDelegate getDcaeReqDeleteDelegate() {
130         return new DcaeReqDeleteDelegate();
131     }
132
133     @Bean(name = "operationalPolicyDelegate")
134     public OperationalPolicyDelegate getOperationalPolicyDelegate() {
135         return new OperationalPolicyDelegate();
136     }
137
138     @Bean(name = "operationalPolicyDeleteDelegate")
139     public OperationalPolicyDeleteDelegate getOperationalPolicyDeleteDelegate() {
140         return new OperationalPolicyDeleteDelegate();
141     }
142
143     @Bean(name = "stringMatchPolicyDelegate")
144     public StringMatchPolicyDelegate getStringMatchPolicyDelegate() {
145         return new StringMatchPolicyDelegate();
146     }
147
148     @Bean(name = "stringMatchPolicyDeleteDelegate")
149     public StringMatchPolicyDeleteDelegate getStringMatchPolicyDeleteDelegate() {
150         return new StringMatchPolicyDeleteDelegate();
151     }
152
153     @Bean(name = "sdcCatalogServices")
154     public SdcCatalogServices getSdcCatalogServices() {
155         return new SdcCatalogServices();
156     }
157
158     @Bean(name = "dcaeDispatcherServices")
159     public DcaeDispatcherServices getDcaeDispatcherServices() {
160         return new DcaeDispatcherServices();
161     }
162
163     @Bean(name = "dcaeInventoryServices")
164     public DcaeInventoryServices getDcaeInventoryServices() {
165         return new DcaeInventoryServices();
166     }
167
168     @Bean(name = "tcaPolicyDelegate")
169     public TcaPolicyDelegate getTcaPolicyDelegate() {
170         return new TcaPolicyDelegate();
171     }
172
173     @Bean(name = "tcaPolicyDeleteDelegate")
174     public TcaPolicyDeleteDelegate getTcaPolicyDeleteDelegate() {
175         return new TcaPolicyDeleteDelegate();
176     }
177
178     @Bean(name = "holmesPolicyDelegate")
179     public HolmesPolicyDelegate getHolmesPolicyDelegate() {
180         return new HolmesPolicyDelegate();
181     }
182
183     @Bean(name = "holmesPolicyDeleteDelegate")
184     public HolmesPolicyDeleteDelegate getHolmesPolicyDeleteDelegate() {
185         return new HolmesPolicyDeleteDelegate();
186     }
187
188 }