Integrate aai-schema-ingest library into aai-core
[aai/aai-common.git] / aai-core / src / main / java / org / onap / aai / config / SpringContextAware.java
index db8de9e..c58d57e 100644 (file)
@@ -19,6 +19,7 @@
  */
 package org.onap.aai.config;
 
+
 import org.springframework.beans.BeansException;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;
@@ -30,11 +31,34 @@ public class SpringContextAware implements ApplicationContextAware {
     private static ApplicationContext context = null;
 
     public static ApplicationContext getApplicationContext() {
-        return context;
+       return context;
     }
 
     @Override
     public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
-        context = applicationContext;
+       context = applicationContext;
+    }
+    
+    
+       public static <T> T getBean(String beanName, Class<T> requiredType) {
+               if(context != null){
+                       return context.getBean(beanName, requiredType);
+                }
+        return null;
+       }
+
+       public static <T> T getBean(Class<T> clazz){
+        if(context != null){
+            return context.getBean(clazz);
+        }
+        return null;
     }
+
+    public static Object getBean(String bean){
+        if(context != null){
+            return context.getBean(bean);
+        }
+        return null;
+    }
+
 }