6b7d337ecab719bd363e3ac58252459c8db4f4fa
[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.HolmesPolicyDelegate;
39 import org.onap.clamp.clds.client.HolmesPolicyDeleteDelegate;
40 import org.onap.clamp.clds.client.OperationalPolicyDelegate;
41 import org.onap.clamp.clds.client.OperationalPolicyDeleteDelegate;
42 import org.onap.clamp.clds.client.PolicyClient;
43 import org.onap.clamp.clds.client.SdcCatalogServices;
44 import org.onap.clamp.clds.client.SdcSendReqDelegate;
45 import org.onap.clamp.clds.client.TcaPolicyDelegate;
46 import org.onap.clamp.clds.client.TcaPolicyDeleteDelegate;
47 import org.onap.clamp.clds.dao.CldsDao;
48 import org.onap.clamp.clds.model.refprop.RefProp;
49 import org.onap.clamp.clds.transform.XslTransformer;
50 import org.springframework.beans.factory.annotation.Autowired;
51 import org.springframework.beans.factory.annotation.Qualifier;
52 import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
53 import org.springframework.boot.context.properties.ConfigurationProperties;
54 import org.springframework.context.ApplicationContext;
55 import org.springframework.context.annotation.Bean;
56 import org.springframework.context.annotation.Configuration;
57 import org.springframework.context.annotation.Profile;
58
59 @Configuration
60 @Profile("clamp-default")
61 public class CldsConfiguration {
62
63     @Autowired
64     private ApplicationContext context;
65
66     /**
67      * Clds Identity database DataSource configuration
68      */
69     @Bean(name = "cldsDataSource")
70     @ConfigurationProperties(prefix = "spring.datasource.cldsdb")
71     public DataSource cldsDataSource() {
72         return DataSourceBuilder.create().build();
73     }
74
75     @Bean(name = "jaxrsProviders")
76     public List<?> jaxrsProviders() {
77         return new ArrayList(context.getBeansWithAnnotation(AjscProvider.class).values());
78     }
79
80     @Bean(name = "jaxrsServices")
81     public List<?> jaxrsServices() {
82         return new ArrayList(context.getBeansWithAnnotation(AjscService.class).values());
83     }
84
85     @Bean(name = "cldsDao")
86     public CldsDao getCldsDao(@Qualifier("cldsDataSource") DataSource dataSource) {
87         CldsDao cldsDao = new CldsDao();
88         cldsDao.setDataSource(dataSource);
89         return cldsDao;
90     }
91
92     @Bean(name = "cldsBpmnTransformer")
93     public XslTransformer getCldsBpmnXslTransformer() throws TransformerConfigurationException {
94         XslTransformer xslTransformer = new XslTransformer();
95         xslTransformer.setXslResourceName("xsl/clds-bpmn-transformer.xsl");
96         return xslTransformer;
97     }
98
99     @Bean
100     public RefProp getRefProp() {
101         return new RefProp();
102     }
103
104     @Bean
105     public PolicyClient getPolicyClient() {
106         return new PolicyClient();
107     }
108
109     @Bean(name = "cldsEventDelegate")
110     public CldsEventDelegate getCldsEventDelegate() {
111         return new CldsEventDelegate();
112     }
113
114     @Bean(name = "sdcSendReqDelegate")
115     public SdcSendReqDelegate getSdcSendReqDelegate() {
116         return new SdcSendReqDelegate();
117     }
118
119     @Bean(name = "operationalPolicyDelegate")
120     public OperationalPolicyDelegate getOperationalPolicyDelegate() {
121         return new OperationalPolicyDelegate();
122     }
123
124     @Bean(name = "operationalPolicyDeleteDelegate")
125     public OperationalPolicyDeleteDelegate getOperationalPolicyDeleteDelegate() {
126         return new OperationalPolicyDeleteDelegate();
127     }
128
129     @Bean(name = "sdcCatalogServices")
130     public SdcCatalogServices getSdcCatalogServices() {
131         return new SdcCatalogServices();
132     }
133
134     @Bean(name = "dcaeDispatcherServices")
135     public DcaeDispatcherServices getDcaeDispatcherServices() {
136         return new DcaeDispatcherServices();
137     }
138
139     @Bean(name = "dcaeInventoryServices")
140     public DcaeInventoryServices getDcaeInventoryServices() {
141         return new DcaeInventoryServices();
142     }
143
144     @Bean(name = "tcaPolicyDelegate")
145     public TcaPolicyDelegate getTcaPolicyDelegate() {
146         return new TcaPolicyDelegate();
147     }
148
149     @Bean(name = "tcaPolicyDeleteDelegate")
150     public TcaPolicyDeleteDelegate getTcaPolicyDeleteDelegate() {
151         return new TcaPolicyDeleteDelegate();
152     }
153
154     @Bean(name = "holmesPolicyDelegate")
155     public HolmesPolicyDelegate getHolmesPolicyDelegate() {
156         return new HolmesPolicyDelegate();
157     }
158
159     @Bean(name = "holmesPolicyDeleteDelegate")
160     public HolmesPolicyDeleteDelegate getHolmesPolicyDeleteDelegate() {
161         return new HolmesPolicyDeleteDelegate();
162     }
163
164 }