/** * Returns an instance for the contextual type, or null if none available. * * @param bean * Contextual type (Bean) for which an instance is desired * @return The instance, or null if none exists */ public <T> T getBean(Contextual<T> bean) { String id = null; if (config.isPortletScoped(bean)) { id = windowId; } return beans.getBeanInstance(id, bean); }
/** * Adds a bean instance with associated creational context to the store for the given contextual object (bean). * * @param bean * The bean type * @param crco * The creational context * @param instance * The bean instance */ public <T> void putBeanInstance(Contextual<T> bean, CreationalContext<T> crco, T instance) { String id = null; if (config.isPortletScoped(bean)) { id = windowId; } beans.putBeanInstance(id, bean, crco, instance); } }
/** * Session binding listener method - unbinding from session. * This occurs only when the session times out or is destroyed (in our case). * * @param arg0 */ @Override public void valueUnbound(HttpSessionBindingEvent evt) { if (isTrace) { LOG.trace("PortletSessionBeanHolder unbound from session. ID=" + evt.getName()); } synchronized(beans) { for (String id : beans.keySet()) { Map<Contextual<?>, BeanInstance<?>> beanMap = beans.get(id); for (Contextual<?> bean : beanMap.keySet()) { remove(id, beanMap, bean); } } beans.clear(); } } }
map = new PortletSessionScopedBeanMap(); ps.setAttribute(ATTRIBNAME, map, PortletSession.APPLICATION_SCOPE); createdMap = true;