ee7cba87447eeb7084e03f2f8cbfc3090bec6e95
[aai/router-core.git] / src / main / java / org / onap / aai / event / EventBusEndpoint.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
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
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 package org.onap.aai.event;
22
23
24 import org.apache.camel.Consumer;
25 import org.apache.camel.Processor;
26 import org.apache.camel.Producer;
27 import org.apache.camel.impl.DefaultEndpoint;
28 import org.apache.camel.spi.Metadata;
29 import org.apache.camel.spi.UriEndpoint;
30 import org.apache.camel.spi.UriParam;
31 import org.apache.camel.spi.UriPath;
32 import org.eclipse.jetty.util.security.Password;
33
34 /**
35  * Represents a EventBus endpoint.
36  */
37 @UriEndpoint(scheme = "event-bus", syntax = "event-bus:name",
38     consumerClass = EventBusConsumer.class, title = "event-bus")
39 public class EventBusEndpoint extends DefaultEndpoint {
40   @UriPath
41   @Metadata(required = "true")
42   private String name;
43
44   @UriParam(label = "eventTopic")
45   @Metadata(required = "true")
46   private String eventTopic;
47   @UriParam(label = "groupName")
48   @Metadata(required = "true")
49   private String groupName;
50   @UriParam(label = "groupId")
51   @Metadata(required = "true")
52   private String groupId;
53   @UriParam(label = "apiKey")
54   private String apiKey;
55   @UriParam(label = "apiSecret")
56   private String apiSecret;
57   @UriParam(label = "url")
58   @Metadata(required = "true")
59   private String url;
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   
67   public EventBusEndpoint() {}
68
69   public EventBusEndpoint(String uri, EventBusComponent component) {
70     super(uri, component);
71   }
72
73   public EventBusEndpoint(String endpointUri) {
74     super(endpointUri);
75   }
76   @Override
77   public Producer createProducer() throws Exception {
78     return new EventBusProducer(this);
79   }
80   @Override
81   public Consumer createConsumer(Processor processor) throws Exception {
82     return new EventBusConsumer(this, processor);
83   }
84   @Override
85   public boolean isSingleton() {
86     return false;
87   }
88
89   public void setName(String name) {
90     this.name = name;
91   }
92
93   public String getName() {
94     return name;
95   }
96
97   public String getEventTopic() {
98     return eventTopic;
99   }
100
101   public void setEventTopic(String eventTopic) {
102     this.eventTopic = eventTopic;
103   }
104
105   public String getGroupName() {
106     return groupName;
107   }
108
109   public void setGroupName(String groupName) {
110     this.groupName = groupName;
111   }
112
113   public String getGroupId() {
114     return groupId;
115   }
116
117   public void setGroupId(String groupId) {
118     this.groupId = groupId;
119   }
120
121   public String getApiKey() {
122     return apiKey == null ? null : Password.deobfuscate(apiKey);
123   }
124
125   public void setApiKey(String apiKey) {
126     this.apiKey = apiKey;
127   }
128
129   public String getApiSecret() {
130     return apiSecret == null ? null : Password.deobfuscate(apiSecret);
131   }
132
133   public void setApiSecret(String apiSecret) {
134     this.apiSecret = apiSecret;
135   }
136   
137   public int getPoolSize() {
138         return poolSize;
139   }
140
141   public void setPoolSize(int poolsize) {
142         this.poolSize = poolsize;
143   }
144
145   public int getPollingDelay() {
146           return pollingDelay;
147   }
148
149   public void setPollingDelay(int pollingDelay) {
150           this.pollingDelay = pollingDelay;
151   }
152
153   public String getUrl() {
154           return url;
155   }
156
157   public void setUrl(String url) {
158     this.url = url;
159   }
160 }
161