d555f39520608b52d3bb49e2e13e9bdf8521f518
[appc.git] / appc-adapters / appc-dmaap-adapter / appc-message-adapter-factory / src / main / java / org / openecomp / appc / adapter / factory / DmaapMessageAdapterFactoryImpl.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Copyright (C) 2017 Amdocs
8  * =============================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  * 
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  * 
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * 
21  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  * ============LICENSE_END=========================================================
23  */
24
25 package org.openecomp.appc.adapter.factory;
26
27 import java.util.Collection;
28 import java.util.Set;
29
30 import org.openecomp.appc.adapter.message.Consumer;
31 import org.openecomp.appc.adapter.message.MessageAdapterFactory;
32 import org.openecomp.appc.adapter.message.Producer;
33
34 import org.openecomp.appc.adapter.messaging.dmaap.http.HttpDmaapConsumerImpl;
35 import org.openecomp.appc.adapter.messaging.dmaap.http.HttpDmaapProducerImpl;
36
37 import org.openecomp.appc.adapter.messaging.dmaap.impl.DmaapConsumerImpl;
38 import org.openecomp.appc.adapter.messaging.dmaap.impl.DmaapProducerImpl;
39
40 public class DmaapMessageAdapterFactoryImpl implements MessageAdapterFactory {
41
42         //Set to true if the HttpDmaap... should be used instead of the regular Dmaap...
43         private static final boolean HTTP = true;
44         
45         public Producer createProducer(Collection<String> pools, String writeTopic, String apiKey, String apiSecret) {
46                 return  HTTP ? new HttpDmaapProducerImpl(pools, writeTopic) : new DmaapProducerImpl(pools, writeTopic,apiKey, apiSecret);
47         }
48
49         public Producer createProducer(Collection<String> pools, Set<String> writeTopics, String apiKey, String apiSecret) {
50                 return HTTP ? new HttpDmaapProducerImpl(pools, writeTopics) : new DmaapProducerImpl(pools, writeTopics, apiKey, apiSecret);
51         }
52
53         public Consumer createConsumer(Collection<String> pool, String readTopic, 
54                         String clientName, String clientId, String filter_json, String apiKey, String apiSecret) {
55                 return HTTP ? new HttpDmaapConsumerImpl(pool, readTopic, clientName, clientId, apiKey, apiSecret, filter_json) : 
56                         new DmaapConsumerImpl(pool, readTopic, clientName, clientId, apiKey, apiSecret, filter_json);
57         }
58 }