2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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.
24 package org.onap.clamp.clds.config;
26 import com.att.ajsc.common.AjscProvider;
27 import com.att.ajsc.common.AjscService;
29 import java.util.ArrayList;
30 import java.util.List;
32 import javax.sql.DataSource;
33 import javax.xml.transform.TransformerConfigurationException;
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;
60 @Profile("clamp-default")
61 public class CldsConfiguration {
64 private ApplicationContext context;
67 * Clds Identity database DataSource configuration
69 @Bean(name = "cldsDataSource")
70 @ConfigurationProperties(prefix = "spring.datasource.cldsdb")
71 public DataSource cldsDataSource() {
72 return DataSourceBuilder.create().build();
75 @Bean(name = "jaxrsProviders")
76 public List<?> jaxrsProviders() {
77 return new ArrayList(context.getBeansWithAnnotation(AjscProvider.class).values());
80 @Bean(name = "jaxrsServices")
81 public List<?> jaxrsServices() {
82 return new ArrayList(context.getBeansWithAnnotation(AjscService.class).values());
85 @Bean(name = "cldsDao")
86 public CldsDao getCldsDao(@Qualifier("cldsDataSource") DataSource dataSource) {
87 CldsDao cldsDao = new CldsDao();
88 cldsDao.setDataSource(dataSource);
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;
100 public RefProp getRefProp() {
101 return new RefProp();
105 public PolicyClient getPolicyClient() {
106 return new PolicyClient();
109 @Bean(name = "cldsEventDelegate")
110 public CldsEventDelegate getCldsEventDelegate() {
111 return new CldsEventDelegate();
114 @Bean(name = "sdcSendReqDelegate")
115 public SdcSendReqDelegate getSdcSendReqDelegate() {
116 return new SdcSendReqDelegate();
119 @Bean(name = "operationalPolicyDelegate")
120 public OperationalPolicyDelegate getOperationalPolicyDelegate() {
121 return new OperationalPolicyDelegate();
124 @Bean(name = "operationalPolicyDeleteDelegate")
125 public OperationalPolicyDeleteDelegate getOperationalPolicyDeleteDelegate() {
126 return new OperationalPolicyDeleteDelegate();
129 @Bean(name = "sdcCatalogServices")
130 public SdcCatalogServices getSdcCatalogServices() {
131 return new SdcCatalogServices();
134 @Bean(name = "dcaeDispatcherServices")
135 public DcaeDispatcherServices getDcaeDispatcherServices() {
136 return new DcaeDispatcherServices();
139 @Bean(name = "dcaeInventoryServices")
140 public DcaeInventoryServices getDcaeInventoryServices() {
141 return new DcaeInventoryServices();
144 @Bean(name = "tcaPolicyDelegate")
145 public TcaPolicyDelegate getTcaPolicyDelegate() {
146 return new TcaPolicyDelegate();
149 @Bean(name = "tcaPolicyDeleteDelegate")
150 public TcaPolicyDeleteDelegate getTcaPolicyDeleteDelegate() {
151 return new TcaPolicyDeleteDelegate();
154 @Bean(name = "holmesPolicyDelegate")
155 public HolmesPolicyDelegate getHolmesPolicyDelegate() {
156 return new HolmesPolicyDelegate();
159 @Bean(name = "holmesPolicyDeleteDelegate")
160 public HolmesPolicyDeleteDelegate getHolmesPolicyDeleteDelegate() {
161 return new HolmesPolicyDeleteDelegate();