View Javadoc

1   /*
2    * Copyright 2023 Bloomreach B.V. (https://www.bloomreach.com)
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *         http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.onehippo.forge.camel.component.hippo;
17  
18  import java.util.Collections;
19  import java.util.Map;
20  import java.util.Set;
21  
22  import org.apache.camel.Consumer;
23  import org.apache.camel.Processor;
24  import org.apache.camel.Producer;
25  import org.apache.camel.support.DefaultEndpoint;
26  
27  /**
28   * 
29   */
30  public class HippoEventEndpoint extends DefaultEndpoint {
31  
32      private final Map<String, Object> properties;
33  
34      protected HippoEventEndpoint(final String endpointUri, final HippoEventComponent component, final Map<String, Object> properties) {
35          super(endpointUri, component);
36          this.properties = properties;
37      }
38  
39      @Override
40      public Consumer createConsumer(Processor processor) throws Exception {
41          HippoEventConsumer answer = new HippoEventConsumer(this, processor);
42          configureConsumer(answer);
43          return answer;
44      }
45  
46      @Override
47      public Producer createProducer() throws Exception {
48          throw new UnsupportedOperationException("Producer is not supported.");
49      }
50  
51      @Override
52      public boolean isSingleton() {
53          return true;
54      }
55  
56      public Set<String> getPropertyNameSet() {
57          if (properties == null) {
58              return Collections.emptySet();
59          }
60  
61          return Collections.unmodifiableSet(properties.keySet());
62      }
63  
64      public Object getProperty(String name) {
65          if (properties != null) {
66              return properties.get(name);
67          }
68  
69          return null;
70      }
71  
72      public boolean hasProperty(String name) {
73          if (properties == null) {
74              return false;
75          }
76  
77          return properties.containsKey(name);
78      }
79  }