/** * Get the current bean, specified by the supplied beanId, from the supplied request. * <p/> * If the specified beanId refers to a bean instance list, this method returns the * last (current) bean from the list. * @param beanId Bean Identifier. * @param executionContext The request on which the bean instance is stored. * @return The bean instance, or null if no such bean instance exists on the supplied * request. * */ public static Object getBean(String beanId, ExecutionContext executionContext) { return getBean(executionContext, beanId); }
/** * Get the bean map associated with the supplied request instance. * @param executionContext The execution context. * @return The bean map associated with the supplied request. * */ public static HashMap<String, Object> getBeans(ExecutionContext executionContext) { warnUsingDeprecatedMethod(); AssertArgument.isNotNull(executionContext, "executionContext"); return (HashMap<String, Object>) getBeanMap(executionContext); }
/** * Add a bean instance to the specified request under the specified beanId. * * @param executionContext The execution context within which the bean is created. * @param beanId The beanId under which the bean is to be stored. * @param bean The bean instance to be stored. */ public static void addBean(ExecutionContext executionContext, String beanId, Object bean) { warnUsingDeprecatedMethod(); AssertArgument.isNotNull(executionContext, "executionContext"); AssertArgument.isNotNullAndNotEmpty(beanId, "beanId"); AssertArgument.isNotNull(bean, "bean"); BeanId beanIdObj = getBeanId(executionContext.getContext().getBeanIdStore(), beanId); executionContext.getBeanContext().addBean(beanIdObj, bean, null); }
/** * @param beanIdStore * @param beanId */ private static BeanId getBeanId(BeanIdStore beanIdStore, String beanId) { warnUsingDeprecatedMethod(); BeanId beanIdObj = beanIdStore.getBeanId(beanId); if (beanIdObj == null) { beanIdObj = beanIdStore.register(beanId); } return beanIdObj; }
/** * Changes a bean object of the given beanId. The difference to addBean is that the * bean must exist, the associated beans aren't removed and the observers of the * {@link BeanLifecycle#CHANGE} event are notified. * * @param executionContext The execution context within which the bean is created. * @param beanId The beanId under which the bean is to be stored. * @param bean The bean instance to be stored. */ public static void changeBean(ExecutionContext executionContext, String beanId, Object bean) { warnUsingDeprecatedMethod(); AssertArgument.isNotNull(executionContext, "executionContext"); AssertArgument.isNotNullAndNotEmpty(beanId, "beanId"); AssertArgument.isNotNull(bean, "bean"); BeanId beanIdObj = getBeanId(executionContext.getContext().getBeanIdStore(), beanId); executionContext.getBeanContext().changeBean(beanIdObj, bean, null); }
/** * Get the bean map associated with the supplied request instance. * @param executionContext The execution context. * @return The bean map associated with the supplied request. */ public static Map<String, Object> getBeanMap(ExecutionContext executionContext) { warnUsingDeprecatedMethod(); AssertArgument.isNotNull(executionContext, "executionContext"); return executionContext.getBeanContext().getBeanMap(); }
/** * Get the current bean, specified by the supplied beanId, from the supplied request. * <p/> * If the specified beanId refers to a bean instance list, this method returns the * last (current) bean from the list. * @param beanId Bean Identifier. * @param executionContext The request on which the bean instance is stored. * @return The bean instance, or null if no such bean instance exists on the supplied * request. */ public static Object getBean(ExecutionContext executionContext, String beanId) { warnUsingDeprecatedMethod(); AssertArgument.isNotNull(executionContext, "executionContext"); AssertArgument.isNotNullAndNotEmpty(beanId, "beanId"); return executionContext.getBeanContext().getBean(beanId); }