aboutsummaryrefslogtreecommitdiffstats
path: root/aai-core/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'aai-core/src/main/java')
-rw-r--r--aai-core/src/main/java/org/onap/aai/config/DmaapConfig.java20
-rw-r--r--aai-core/src/main/java/org/onap/aai/config/EventClientPublisher.java4
-rw-r--r--aai-core/src/main/java/org/onap/aai/config/SpringContextAware.java2
-rw-r--r--aai-core/src/main/java/org/onap/aai/dmaap/AAIDmaapEventJMSConsumer.java27
-rw-r--r--aai-core/src/main/java/org/onap/aai/dmaap/AAIDmaapEventJMSProducer.java6
5 files changed, 34 insertions, 25 deletions
diff --git a/aai-core/src/main/java/org/onap/aai/config/DmaapConfig.java b/aai-core/src/main/java/org/onap/aai/config/DmaapConfig.java
index 7634b74c..b2b5bccd 100644
--- a/aai-core/src/main/java/org/onap/aai/config/DmaapConfig.java
+++ b/aai-core/src/main/java/org/onap/aai/config/DmaapConfig.java
@@ -24,20 +24,36 @@ import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.command.ActiveMQQueue;
import org.onap.aai.dmaap.AAIDmaapEventJMSConsumer;
import org.onap.aai.dmaap.AAIDmaapEventJMSProducer;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
+import org.springframework.http.HttpHeaders;
import org.springframework.jms.connection.CachingConnectionFactory;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.listener.DefaultMessageListenerContainer;
import javax.annotation.PostConstruct;
+import org.springframework.web.client.RestTemplate;
@Profile("dmaap")
@Configuration
public class DmaapConfig {
+ @Autowired
+ private ApplicationContext ctx;
+
+ @Autowired
+ @Qualifier("dmaapRestTemplate")
+ private RestTemplate dmaapRestTemplate;
+
+ @Autowired
+ @Qualifier("dmaapHeaders")
+ private HttpHeaders dmaapHeaders;
+
@Value("${jms.bind.address}")
private String bindAddress;
@@ -89,9 +105,9 @@ public class DmaapConfig {
return new AAIDmaapEventJMSProducer();
}
- @Bean
+ @Bean(name="jmsConsumer")
public AAIDmaapEventJMSConsumer jmsConsumer() throws Exception {
- return new AAIDmaapEventJMSConsumer();
+ return new AAIDmaapEventJMSConsumer(ctx.getEnvironment(), dmaapRestTemplate, dmaapHeaders);
}
@Bean
diff --git a/aai-core/src/main/java/org/onap/aai/config/EventClientPublisher.java b/aai-core/src/main/java/org/onap/aai/config/EventClientPublisher.java
index 1268bf84..9567dd87 100644
--- a/aai-core/src/main/java/org/onap/aai/config/EventClientPublisher.java
+++ b/aai-core/src/main/java/org/onap/aai/config/EventClientPublisher.java
@@ -67,12 +67,12 @@ public class EventClientPublisher {
@Value("${dmaap.ribbon.contentType:application/json}")
private String contentType;
- @Bean
+ @Bean(name="dmaapRestTemplate")
public RestTemplate dmaapRestTemplate(){
return new RestTemplate();
}
- @Bean
+ @Bean(name="dmaapHeaders")
public HttpHeaders dmaapHeaders() throws UnsupportedEncodingException
{
diff --git a/aai-core/src/main/java/org/onap/aai/config/SpringContextAware.java b/aai-core/src/main/java/org/onap/aai/config/SpringContextAware.java
index db8de9ec..d8043d4c 100644
--- a/aai-core/src/main/java/org/onap/aai/config/SpringContextAware.java
+++ b/aai-core/src/main/java/org/onap/aai/config/SpringContextAware.java
@@ -37,4 +37,4 @@ public class SpringContextAware implements ApplicationContextAware {
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
context = applicationContext;
}
-}
+} \ No newline at end of file
diff --git a/aai-core/src/main/java/org/onap/aai/dmaap/AAIDmaapEventJMSConsumer.java b/aai-core/src/main/java/org/onap/aai/dmaap/AAIDmaapEventJMSConsumer.java
index 5e28b3af..49cc0e90 100644
--- a/aai-core/src/main/java/org/onap/aai/dmaap/AAIDmaapEventJMSConsumer.java
+++ b/aai-core/src/main/java/org/onap/aai/dmaap/AAIDmaapEventJMSConsumer.java
@@ -21,26 +21,24 @@ package org.onap.aai.dmaap;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
+import java.util.Objects;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.TextMessage;
import org.apache.log4j.MDC;
import org.json.JSONException;
import org.json.JSONObject;
-import org.onap.aai.config.SpringContextAware;
import org.onap.aai.logging.LogFormatTools;
import org.onap.aai.logging.LoggingContext;
import org.onap.aai.logging.LoggingContext.LoggingField;
import org.onap.aai.logging.LoggingContext.StatusCode;
-import org.springframework.context.ApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.web.client.RestTemplate;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import javax.jms.TextMessage;
-
public class AAIDmaapEventJMSConsumer implements MessageListener {
private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(AAIDmaapEventJMSConsumer.class);
@@ -51,14 +49,13 @@ public class AAIDmaapEventJMSConsumer implements MessageListener {
private Environment environment;
- public AAIDmaapEventJMSConsumer() {
- ApplicationContext applicationContext = SpringContextAware.getApplicationContext();
-
- if(applicationContext != null){
- restTemplate = (RestTemplate) applicationContext.getBean("dmaapRestTemplate");
- httpHeaders = (HttpHeaders) applicationContext.getBean("dmaapHeaders");
- environment = applicationContext.getEnvironment();
- }
+ public AAIDmaapEventJMSConsumer(Environment environment, RestTemplate restTemplate, HttpHeaders httpHeaders) {
+ Objects.nonNull(environment);
+ Objects.nonNull(restTemplate);
+ Objects.nonNull(httpHeaders);
+ this.environment = environment;
+ this.restTemplate = restTemplate;
+ this.httpHeaders = httpHeaders;
}
@Override
diff --git a/aai-core/src/main/java/org/onap/aai/dmaap/AAIDmaapEventJMSProducer.java b/aai-core/src/main/java/org/onap/aai/dmaap/AAIDmaapEventJMSProducer.java
index dc803b15..851a22fe 100644
--- a/aai-core/src/main/java/org/onap/aai/dmaap/AAIDmaapEventJMSProducer.java
+++ b/aai-core/src/main/java/org/onap/aai/dmaap/AAIDmaapEventJMSProducer.java
@@ -8,7 +8,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -22,9 +22,7 @@ package org.onap.aai.dmaap;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.command.ActiveMQQueue;
import org.json.JSONObject;
-import org.onap.aai.config.SpringContextAware;
import org.onap.aai.util.AAIConfig;
-import org.springframework.context.ApplicationContext;
import org.springframework.jms.connection.CachingConnectionFactory;
import org.springframework.jms.core.JmsTemplate;
@@ -32,8 +30,6 @@ public class AAIDmaapEventJMSProducer implements MessageProducer {
private JmsTemplate jmsTemplate;
- private ApplicationContext applicationContext;
-
public AAIDmaapEventJMSProducer() {
if(AAIConfig.get("aai.jms.enable", "true").equals("true")){
this.jmsTemplate = new JmsTemplate();