public Object getInstance() throws InstantiationException { // fills for the first time the moduleConfig ActionForm formInstance = (ActionForm) WebContextFactory.get().getSession().getAttribute(formBean); if (formInstance == null) { throw new InstantiationException("Can't find formInstance for " + formBean); } return formInstance; }
@Override public HttpSession get() { return WebContextFactory.get().getSession(); }
public HttpSession get() { WebContext webcx = WebContextFactory.get(); return webcx.getSession(); }
/** * Internal method to find or create a StoreProvider for a given user. */ @Override protected StoreProvider<T> getStoreProvider() { HttpSession session = WebContextFactory.get().getSession(true); @SuppressWarnings("unchecked") StoreProvider<T> storeProvider = (StoreProvider<T>) session.getAttribute(attributeName); if (storeProvider == null) { storeProvider = factory.create(session); session.setAttribute(attributeName, storeProvider); } return storeProvider; }
/** * Method responsible for generating form for reporting errors. * @param elementId * @return */ public Map<String, Object> getForm(String elementId) { Map<String, Object> result = new HashMap<String, Object>(); try { Map<String, Object> model = new HashMap<String, Object>(); WebContext context = WebContextFactory.get(); String captchaId = captchaIdGenerator.getId(context.getSession().getId()); model.put("captchaId", captchaId); model.put("extId", elementId); model.put("logged", false); model.put("timestamp", (new Date()).getTime()); context.getHttpServletRequest().setAttribute("viewModel", model); String html = context.forwardToString(forcedViewName); result.put(DWRConstants.CONTENT, html); } catch (Exception e) { log.warn("Exception occurred when rendering DWR error form for element " + elementId, e); result.put(DWRConstants.ERROR, messageSource.getMessage( MessageConstants.DWR_NO_DATA, null, LocaleContextHolder.getLocale())); } return result; }
@SuppressWarnings("unchecked") private List<LongPollData> getLongPollData() { HttpSession session = WebContextFactory.get().getSession();
public Object convertInbound(Class<?> paramType, InboundVariable data) { WebContext webcx = WebContextFactory.get(); if (HttpServletRequest.class.isAssignableFrom(paramType)) { return webcx.getHttpServletRequest(); } if (HttpServletResponse.class.isAssignableFrom(paramType)) { return webcx.getHttpServletResponse(); } if (ServletConfig.class.isAssignableFrom(paramType)) { return webcx.getServletConfig(); } if (ServletContext.class.isAssignableFrom(paramType)) { return webcx.getServletContext(); } if (HttpSession.class.isAssignableFrom(paramType)) { return webcx.getSession(true); } return null; }
object = webcx.getSession().getAttribute(name); webcx.getSession().setAttribute(name, object);
try { String cid = captchaIdGenerator.getId( context.getSession().getId()); model.put("captchaId", cid); model.put("extId", elementId);
HttpSession httpSession = webCtx.getSession(false); String httpSessionId = (httpSession != null ? httpSession.getId() : null);
public DynamicServerInfo getJavaVMStatistics() { HttpSession session = WebContextFactory.get().getSession(true); ManagementHelper helper = PortletManager.getManagementHelper(session); J2EEDomain[] domains = helper.getDomains(); J2EEServer[] servers = domains[0].getServerInstances(); JVM[] jvms = helper.getJavaVMs(servers[0]); long elapsed = System.currentTimeMillis() - jvms[0].getKernelBootTime().getTime(); if(jvms[0].isStatisticsProvider()) { JVMStats stats = (JVMStats) ((StatisticsProvider)jvms[0]).getStats(); BoundedRangeStatistic heap = stats.getHeapSize(); return new DynamicServerInfo(heap.getCurrent(), heap.getHighWaterMark(), heap.getUpperBound(), elapsed); } else { return new DynamicServerInfo(elapsed); } } }