All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.nichetoolkit.rest.util.ContextUtils Maven / Gradle / Ivy

There is a newer version: 1.1.0
Show newest version
package io.github.nichetoolkit.rest.util;

import io.github.nichetoolkit.rest.holder.ContextHolder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeansException;

import java.util.List;

/**
 * 

ContextUtils

* @author Cyan ([email protected]) * @version v1.0.0 */ @Slf4j public class ContextUtils { public static Object getBean(String name){ try { return ContextHolder.getBean(name); } catch (BeansException ex) { log.warn("bean of name is {} no found, error: {}",name,ex.getMessage()); return null; } } public static T getBean(Class clazz){ try { return ContextHolder.getBean(clazz); } catch (BeansException ex) { log.warn("bean of type is {} no found, error: {}",clazz.getName(),ex.getMessage()); return null; } } public static T getBean(String name, Class clazz){ try { return ContextHolder.getBean(name, clazz); } catch (BeansException ex) { log.warn("bean of type is {} and name is {} no found, error: {}",clazz.getName(),name,ex.getMessage()); return null; } } public static List getBeans(Class clazz){ try { return ContextHolder.getBeans(clazz); } catch (BeansException ex) { log.warn("beans of type is {} no found, error: {}",clazz.getName(),ex.getMessage()); return null; } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy