/** * Return the bean instances that match the given object type (including * subclasses). * <p>The Map returned by this method should always return bean names and * corresponding bean instances <i>in the order of definition</i> in the * backend configuration, as far as possible. * @param beanType the class or interface to match, or <code>null</code> for all concrete beans * @return a Map with the matching beans, containing the bean names as * keys and the corresponding bean instances as values */ public static <T> Map<String, T> getAll(Class<T> beanType) { return getBeanLocator().getAll(beanType); }
/** * Create all Web handlers defined by <code>ExceptionHandlersConfiguration</code> beans in spring.xml and * GUI handlers defined as Spring-beans. */ public void createByConfiguration() { removeAll(); // Web handlers Map<String, ExceptionHandlersConfiguration> map = beanLocator.getAll(ExceptionHandlersConfiguration.class); // Project-level handlers must run before platform-level List<ExceptionHandlersConfiguration> configurations = new ArrayList<>(map.values()); Collections.reverse(configurations); for (ExceptionHandlersConfiguration conf : configurations) { for (Class aClass : conf.getHandlerClasses()) { try { addHandler(ReflectionHelper.<ExceptionHandler>newInstance(aClass)); } catch (NoSuchMethodException e) { log.error("Unable to instantiate {}", aClass, e); } } } // GUI handlers Map<String, UiExceptionHandler> handlerMap = beanLocator.getAll(UiExceptionHandler.class); List<UiExceptionHandler> handlers = new ArrayList<>(handlerMap.values()); handlers.sort(new OrderComparator()); for (UiExceptionHandler handler : handlers) { addHandler(handler); } }
Object instance; Map<String, ?> beans = beanLocator.getAll(type); if (!beans.isEmpty()) { instance = beans.get(name);
Object instance; Map<String, ?> beans = beanLocator.getAll(type); if (!beans.isEmpty()) { instance = beans.get(name);