/** Returns a specific bean given its name with a specified application context. */ public static final Object bean(String name, ApplicationContext context) { checkContext(context, name); if (context != null) { return getBean(context, name); } else { Object bean = singletonBeanCache.get(name); return bean; } }
/** * Loads a single bean by its type. * * <p>This method returns null if there is no such bean. An exception is thrown if multiple * beans of the specified type exist. * * @param type THe type of the bean to lookup. * @throws MultipleBeansException If there are multiple beans of the specified type in the * context. */ public static final <T> T bean(Class<T> type) throws IllegalArgumentException { checkContext(context, type.getSimpleName()); return bean(type, context); }
checkContext(context, extensionPoint.getSimpleName()); if (context != null) { try {
/** * Returns a specific bean given its name * @param name * @return */ public static final Object bean(String name) { checkContext(context); return context != null ? context.getBean(name) : null; }
/** * Loads a single bean by its type. * <p> * This method returns null if there is no such bean. An exception is thrown * if multiple beans of the specified type exist. * </p> * * @param type THe type of the bean to lookup. * * @throws IllegalArgumentException If there are multiple beans of the specified * type in the context. */ public static final <T> T bean(Class<T> type) throws IllegalArgumentException { checkContext(context); return context != null ? bean( type, context ) : null; }
checkContext(context); if ( context != null ) { try {