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