|
@@ -0,0 +1,262 @@
|
|
|
+package com.cqxf.prometheus.alert.utils;
|
|
|
+
|
|
|
+import org.springframework.beans.BeansException;
|
|
|
+import org.springframework.beans.factory.BeanFactory;
|
|
|
+import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
|
|
+import org.springframework.beans.factory.ObjectProvider;
|
|
|
+import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
|
|
|
+import org.springframework.context.ApplicationContext;
|
|
|
+import org.springframework.context.ApplicationContextAware;
|
|
|
+import org.springframework.context.MessageSourceResolvable;
|
|
|
+import org.springframework.context.NoSuchMessageException;
|
|
|
+import org.springframework.core.ResolvableType;
|
|
|
+import org.springframework.core.env.Environment;
|
|
|
+import org.springframework.core.io.Resource;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.io.IOException;
|
|
|
+import java.lang.annotation.Annotation;
|
|
|
+import java.util.Locale;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+@Component("appContext")
|
|
|
+public class AppContext implements ApplicationContextAware, ApplicationContext{
|
|
|
+
|
|
|
+ private ApplicationContext applicationContext;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
|
|
+ this.applicationContext = applicationContext;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String getId() {
|
|
|
+ return applicationContext.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String getApplicationName() {
|
|
|
+ return applicationContext.getApplicationName();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String getDisplayName() {
|
|
|
+ return applicationContext.getDisplayName();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public long getStartupDate() {
|
|
|
+ return applicationContext.getStartupDate();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ApplicationContext getParent() {
|
|
|
+ return applicationContext.getParent();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public AutowireCapableBeanFactory getAutowireCapableBeanFactory() throws IllegalStateException {
|
|
|
+ return applicationContext.getAutowireCapableBeanFactory();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public BeanFactory getParentBeanFactory() {
|
|
|
+ return applicationContext.getParentBeanFactory();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean containsLocalBean(String s) {
|
|
|
+ return applicationContext.containsLocalBean(s);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean containsBeanDefinition(String s) {
|
|
|
+ return applicationContext.containsBeanDefinition(s);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int getBeanDefinitionCount() {
|
|
|
+ return applicationContext.getBeanDefinitionCount();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String[] getBeanDefinitionNames() {
|
|
|
+ return applicationContext.getBeanDefinitionNames();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public <T> ObjectProvider<T> getBeanProvider(Class<T> aClass, boolean b) {
|
|
|
+ return applicationContext.getBeanProvider(aClass, b);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public <T> ObjectProvider<T> getBeanProvider(ResolvableType resolvableType, boolean b) {
|
|
|
+ return applicationContext.getBeanProvider(resolvableType, b);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String[] getBeanNamesForType(ResolvableType resolvableType) {
|
|
|
+ return applicationContext.getBeanNamesForType(resolvableType);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String[] getBeanNamesForType(ResolvableType resolvableType, boolean b, boolean b1) {
|
|
|
+ return applicationContext.getBeanNamesForType(resolvableType, b, b1);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String[] getBeanNamesForType(Class<?> aClass) {
|
|
|
+ return applicationContext.getBeanNamesForType(aClass);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String[] getBeanNamesForType(Class<?> aClass, boolean b, boolean b1) {
|
|
|
+ return applicationContext.getBeanNamesForType(aClass, b, b1);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public <T> Map<String, T> getBeansOfType(Class<T> aClass) throws BeansException {
|
|
|
+ return applicationContext.getBeansOfType(aClass);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public <T> Map<String, T> getBeansOfType(Class<T> aClass, boolean b, boolean b1) throws BeansException {
|
|
|
+ return applicationContext.getBeansOfType(aClass, b, b1);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String[] getBeanNamesForAnnotation(Class<? extends Annotation> aClass) {
|
|
|
+ return applicationContext.getBeanNamesForAnnotation(aClass);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> getBeansWithAnnotation(Class<? extends Annotation> aClass) throws BeansException {
|
|
|
+ return applicationContext.getBeansWithAnnotation(aClass);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public <A extends Annotation> A findAnnotationOnBean(String s, Class<A> aClass) throws NoSuchBeanDefinitionException {
|
|
|
+ return applicationContext.findAnnotationOnBean(s, aClass);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public <A extends Annotation> A findAnnotationOnBean(String s, Class<A> aClass, boolean b) throws NoSuchBeanDefinitionException {
|
|
|
+ return applicationContext.findAnnotationOnBean(s, aClass, b);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Object getBean(String s) throws BeansException {
|
|
|
+ return applicationContext.getBean(s);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public <T> T getBean(String s, Class<T> aClass) throws BeansException {
|
|
|
+ return applicationContext.getBean(s, aClass);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Object getBean(String s, Object... objects) throws BeansException {
|
|
|
+ return applicationContext.getBean(s, objects);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public <T> T getBean(Class<T> aClass) throws BeansException {
|
|
|
+ return applicationContext.getBean(aClass);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public <T> T getBean(Class<T> aClass, Object... objects) throws BeansException {
|
|
|
+ return applicationContext.getBean(aClass, objects);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public <T> ObjectProvider<T> getBeanProvider(Class<T> aClass) {
|
|
|
+ return applicationContext.getBeanProvider(aClass);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public <T> ObjectProvider<T> getBeanProvider(ResolvableType resolvableType) {
|
|
|
+ return applicationContext.getBeanProvider(resolvableType);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean containsBean(String s) {
|
|
|
+ return applicationContext.containsBean(s);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean isSingleton(String s) throws NoSuchBeanDefinitionException {
|
|
|
+ return applicationContext.isSingleton(s);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean isPrototype(String s) throws NoSuchBeanDefinitionException {
|
|
|
+ return applicationContext.isPrototype(s);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean isTypeMatch(String s, ResolvableType resolvableType) throws NoSuchBeanDefinitionException {
|
|
|
+ return applicationContext.isTypeMatch(s, resolvableType);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean isTypeMatch(String s, Class<?> aClass) throws NoSuchBeanDefinitionException {
|
|
|
+ return applicationContext.isTypeMatch(s, aClass);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Class<?> getType(String s) throws NoSuchBeanDefinitionException {
|
|
|
+ return applicationContext.getType(s);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Class<?> getType(String s, boolean b) throws NoSuchBeanDefinitionException {
|
|
|
+ return applicationContext.getType(s, b);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String[] getAliases(String s) {
|
|
|
+ return applicationContext.getAliases(s);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void publishEvent(Object event) {
|
|
|
+ applicationContext.publishEvent(event);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String getMessage(String code, Object[] args, String defaultMessage, Locale locale) {
|
|
|
+ return applicationContext.getMessage(code, args, defaultMessage, locale);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String getMessage(String code, Object[] args, Locale locale) throws NoSuchMessageException {
|
|
|
+ return applicationContext.getMessage(code, args, locale);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String getMessage(MessageSourceResolvable resolvable, Locale locale) throws NoSuchMessageException {
|
|
|
+ return applicationContext.getMessage(resolvable, locale);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Environment getEnvironment() {
|
|
|
+ return applicationContext.getEnvironment();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Resource[] getResources(String locationPattern) throws IOException {
|
|
|
+ return applicationContext.getResources(locationPattern);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Resource getResource(String location) {
|
|
|
+ return applicationContext.getResource(location);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ClassLoader getClassLoader() {
|
|
|
+ return applicationContext.getClassLoader();
|
|
|
+ }
|
|
|
+}
|