[CLAMP-1] Initial ONAP CLAMP seed code commit
[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 import org.onap.clamp.clds.client.*;
29 import org.onap.clamp.clds.dao.CldsDao;
30 import org.onap.clamp.clds.model.refprop.RefProp;
31 import org.onap.clamp.clds.transform.XslTransformer;
32 import org.springframework.beans.factory.annotation.Autowired;
33 import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
34 import org.springframework.boot.context.properties.ConfigurationProperties;
35 import org.springframework.context.ApplicationContext;
36 import org.springframework.context.annotation.Bean;
37 import org.springframework.context.annotation.Configuration;
38 import org.springframework.context.annotation.Profile;
39
40 import javax.sql.DataSource;
41 import javax.xml.transform.TransformerConfigurationException;
42 import java.io.IOException;
43 import java.util.ArrayList;
44 import java.util.List;
45
46 @Configuration
47 @Profile("clamp-default")
48 public class CldsConfiguration {
49
50     @Autowired
51     private ApplicationContext context;
52
53     /**
54      * Clds Identity databse DataSource configuration
55      */
56     @Bean(name = "cldsDataSource")
57     @ConfigurationProperties(prefix = "spring.cldsdatasource")
58     public DataSource cldsDataSource() {
59         return DataSourceBuilder
60                 .create()
61                 .build();
62     }
63
64     @Bean(name = "jaxrsProviders")
65     public List jaxrsProviders() {
66         return new ArrayList(context.getBeansWithAnnotation(AjscProvider.class).values());
67     }
68
69     @Bean(name = "jaxrsServices")
70     public List jaxrsServices() {
71         return new ArrayList(context.getBeansWithAnnotation(AjscService.class).values());
72     }
73
74     @Bean(name = "cldsDao")
75     public CldsDao getCldsDao() {
76         CldsDao cldsDao = new CldsDao();
77         cldsDao.setDataSource(cldsDataSource());
78         return cldsDao;
79     }
80
81     @Bean(name = "cldsBpmnTransformer")
82     public XslTransformer getCldsBpmnXslTransformer() throws TransformerConfigurationException {
83         XslTransformer xslTransformer = new XslTransformer();
84         xslTransformer.setXslResourceName("xsl/clds-bpmn-transformer.xsl");
85         return xslTransformer;
86     }
87
88     @Bean
89     public RefProp getRefProp() throws IOException {
90         return new RefProp();
91     }
92
93     @Bean
94     public PolicyClient getPolicyClient() {
95         return new PolicyClient();
96     }
97
98     @Bean(name = "cldsEventDelegate")
99     public CldsEventDelegate getCldsEventDelegate() {
100         return new CldsEventDelegate();
101     }
102
103     @Bean(name = "dcaeReqDelegate")
104     public DcaeReqDelegate getDcaeReqDelegate() {
105         return new DcaeReqDelegate();
106     }
107
108     @Bean(name = "sdcSendReqDelegate")
109     public SdcSendReqDelegate getSdcSendReqDelegate() {
110         return new SdcSendReqDelegate();
111     }
112
113     @Bean(name = "dcaeReqDeleteDelegate")
114     public DcaeReqDeleteDelegate getDcaeReqDeleteDelegate() {
115         return new DcaeReqDeleteDelegate();
116     }
117
118     @Bean(name = "operationalPolicyDelegate")
119     public OperationalPolicyDelegate getOperationalPolicyDelegate() {
120         return new OperationalPolicyDelegate();
121     }
122
123     @Bean(name = "operationalPolicyDeleteDelegate")
124     public OperationalPolicyDeleteDelegate getOperationalPolicyDeleteDelegate() {
125         return new OperationalPolicyDeleteDelegate();
126     }
127
128     @Bean(name = "stringMatchPolicyDelegate")
129     public StringMatchPolicyDelegate getStringMatchPolicyDelegate() {
130         return new StringMatchPolicyDelegate();
131     }
132
133     @Bean(name = "stringMatchPolicyDeleteDelegate")
134     public StringMatchPolicyDeleteDelegate getStringMatchPolicyDeleteDelegate() {
135         return new StringMatchPolicyDeleteDelegate();
136     }
137
138     @Bean(name = "sdcCatalogServices")
139     public SdcCatalogServices getAsdcCatalogServices() {
140         return new SdcCatalogServices();
141     }
142 }