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.StringMatchPolicyDelegate;
46 import org.onap.clamp.clds.client.StringMatchPolicyDeleteDelegate;
47 import org.onap.clamp.clds.client.TcaPolicyDelegate;
48 import org.onap.clamp.clds.client.TcaPolicyDeleteDelegate;
49 import org.onap.clamp.clds.dao.CldsDao;
50 import org.onap.clamp.clds.model.refprop.RefProp;
51 import org.onap.clamp.clds.transform.XslTransformer;
52 import org.springframework.beans.factory.annotation.Autowired;
53 import org.springframework.beans.factory.annotation.Qualifier;
54 import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
55 import org.springframework.boot.context.properties.ConfigurationProperties;
56 import org.springframework.context.ApplicationContext;
57 import org.springframework.context.annotation.Bean;
58 import org.springframework.context.annotation.Configuration;
59 import org.springframework.context.annotation.Profile;
62 @Profile("clamp-default")
63 public class CldsConfiguration {
66 private ApplicationContext context;
69 * Clds Identity database DataSource configuration
71 @Bean(name = "cldsDataSource")
72 @ConfigurationProperties(prefix = "spring.datasource.cldsdb")
73 public DataSource cldsDataSource() {
74 return DataSourceBuilder.create().build();
77 @Bean(name = "jaxrsProviders")
78 public List<?> jaxrsProviders() {
79 return new ArrayList(context.getBeansWithAnnotation(AjscProvider.class).values());
82 @Bean(name = "jaxrsServices")
83 public List<?> jaxrsServices() {
84 return new ArrayList(context.getBeansWithAnnotation(AjscService.class).values());
87 @Bean(name = "cldsDao")
88 public CldsDao getCldsDao(@Qualifier("cldsDataSource") DataSource dataSource) {
89 CldsDao cldsDao = new CldsDao();
90 cldsDao.setDataSource(dataSource);
94 @Bean(name = "cldsBpmnTransformer")
95 public XslTransformer getCldsBpmnXslTransformer() throws TransformerConfigurationException {
96 XslTransformer xslTransformer = new XslTransformer();
97 xslTransformer.setXslResourceName("xsl/clds-bpmn-transformer.xsl");
98 return xslTransformer;
102 public RefProp getRefProp() {
103 return new RefProp();
107 public PolicyClient getPolicyClient() {
108 return new PolicyClient();
111 @Bean(name = "cldsEventDelegate")
112 public CldsEventDelegate getCldsEventDelegate() {
113 return new CldsEventDelegate();
116 @Bean(name = "sdcSendReqDelegate")
117 public SdcSendReqDelegate getSdcSendReqDelegate() {
118 return new SdcSendReqDelegate();
121 @Bean(name = "operationalPolicyDelegate")
122 public OperationalPolicyDelegate getOperationalPolicyDelegate() {
123 return new OperationalPolicyDelegate();
126 @Bean(name = "operationalPolicyDeleteDelegate")
127 public OperationalPolicyDeleteDelegate getOperationalPolicyDeleteDelegate() {
128 return new OperationalPolicyDeleteDelegate();
131 @Bean(name = "stringMatchPolicyDelegate")
132 public StringMatchPolicyDelegate getStringMatchPolicyDelegate() {
133 return new StringMatchPolicyDelegate();
136 @Bean(name = "stringMatchPolicyDeleteDelegate")
137 public StringMatchPolicyDeleteDelegate getStringMatchPolicyDeleteDelegate() {
138 return new StringMatchPolicyDeleteDelegate();
141 @Bean(name = "sdcCatalogServices")
142 public SdcCatalogServices getSdcCatalogServices() {
143 return new SdcCatalogServices();
146 @Bean(name = "dcaeDispatcherServices")
147 public DcaeDispatcherServices getDcaeDispatcherServices() {
148 return new DcaeDispatcherServices();
151 @Bean(name = "dcaeInventoryServices")
152 public DcaeInventoryServices getDcaeInventoryServices() {
153 return new DcaeInventoryServices();
156 @Bean(name = "tcaPolicyDelegate")
157 public TcaPolicyDelegate getTcaPolicyDelegate() {
158 return new TcaPolicyDelegate();
161 @Bean(name = "tcaPolicyDeleteDelegate")
162 public TcaPolicyDeleteDelegate getTcaPolicyDeleteDelegate() {
163 return new TcaPolicyDeleteDelegate();
166 @Bean(name = "holmesPolicyDelegate")
167 public HolmesPolicyDelegate getHolmesPolicyDelegate() {
168 return new HolmesPolicyDelegate();
171 @Bean(name = "holmesPolicyDeleteDelegate")
172 public HolmesPolicyDeleteDelegate getHolmesPolicyDeleteDelegate() {
173 return new HolmesPolicyDeleteDelegate();