2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017-2018 Amdocs
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=========================================================
21 package org.onap.aai.event;
24 import org.apache.camel.Consumer;
25 import org.apache.camel.Processor;
26 import org.apache.camel.Producer;
27 import org.apache.camel.spi.Metadata;
28 import org.apache.camel.spi.UriEndpoint;
29 import org.apache.camel.spi.UriParam;
30 import org.apache.camel.spi.UriPath;
31 import org.eclipse.jetty.util.security.Password;
32 import org.onap.aai.event.client.DMaaPEventConsumer;
35 * Represents a EventBus endpoint.
37 @UriEndpoint(scheme = "dmaap-event-bus", syntax = "dmaap-event-bus:name",
38 consumerClass = EventBusConsumer.class, title = "dmaap-event-bus")
39 public class DMaaPEventBusEndpoint extends AbstractEventBusEndpoint {
41 @Metadata(required = "true")
44 @UriParam(label = "eventTopic")
45 @Metadata(required = "true")
46 private String eventTopic;
47 @UriParam(label = "consumerGroup")
48 @Metadata(required = "true")
49 private String consumerGroup;
50 @UriParam(label = "consumerId")
51 @Metadata(required = "true")
52 private String consumerId;
53 @UriParam(label = "username")
54 private String username;
55 @UriParam(label = "password")
56 private String password;
57 @UriParam(label = "url")
58 @Metadata(required = "true")
60 @UriParam(label = "poolSize")
61 @Metadata(required = "true", defaultValue="20")
62 private int poolSize = 20;
63 @UriParam(label = "pollingDelay")
64 @Metadata(required = "true", defaultValue="30000")
65 private int pollingDelay = 30000;
66 @UriParam(label = "transportType")
67 @Metadata(required = "true", defaultValue="HTTPAUTH")
68 private String transportType;
70 private DMaaPEventConsumer dmaapConsumer;
72 public DMaaPEventBusEndpoint() {}
74 public DMaaPEventBusEndpoint(String uri, DMaaPEventBusComponent component) {
75 super(uri, component);
78 public DMaaPEventBusEndpoint(String endpointUri) {
84 // Don't have to do anything for DMaaP
88 public Producer createProducer() throws Exception {
89 return new EventBusProducer(this);
92 public Consumer createConsumer(Processor processor) throws Exception {
93 // TODO: other overloads based on filled-in properties
94 dmaapConsumer = new DMaaPEventConsumer(url, eventTopic, Password.deobfuscate(username), Password.deobfuscate(password), consumerGroup, consumerId, 15000, 1000, transportType);
95 return new EventBusConsumer(this, processor, dmaapConsumer);
98 public boolean isSingleton() {
102 public void setName(String name) {
106 public String getName() {
110 public String getEventTopic() {
114 public void setEventTopic(String eventTopic) {
115 this.eventTopic = eventTopic;
118 public String getConsumerGroup() {
119 return consumerGroup;
122 public void setConsumerGroup(String consumerGroup) {
123 this.consumerGroup = consumerGroup;
126 public String getConsumerId() {
130 public void setConsumerId(String consumerId) {
131 this.consumerId = consumerId;
134 public String getUsername() {
135 return username == null ? null : Password.deobfuscate(username);
139 public void setUsername(String username) {
140 this.username = username;
143 public String getPassword() {
144 return password == null ? null : Password.deobfuscate(password);
148 public void setPassword(String password) {
149 this.password = password;
152 public int getPoolSize() {
156 public void setPoolSize(int poolsize) {
157 this.poolSize = poolsize;
160 public int getPollingDelay() {
164 public void setPollingDelay(int pollingDelay) {
165 this.pollingDelay = pollingDelay;
168 public String getUrl() {
172 public void setUrl(String url) {
176 public String getTransportType() {
177 return transportType;
180 public void setTransportType(String transportType) {
181 this.transportType = transportType;