/** * Internal method to allow us to get the WebContextBuilder from which we * will get WebContext objects. * Do NOT call this method from outside of DWR. */ public static void attach(Container container) { WebContextFactory.builder = container.getBean(WebContextBuilder.class); }
/** * Read the {@link Container} and cache the values */ private void init() { if (proxy == null) { proxy = new HashMap<String, Object>(); for (String name : container.getBeanNames()) { Object value = container.getBean(name); if (!filterNonStringValues || value instanceof String) { proxy.put(name, value); } } } }
/** * Internal helper for getting at a ConverterManager * @return Our ConverterManager */ protected ConverterManager getConverterManager() { if (converterManager == null) { converterManager = container.getBean(ConverterManager.class); } return converterManager; }
/** * */ public static ConverterManager getConverterManager() { return container.getBean(ConverterManager.class); }
/** * Internal helper for getting at a ScriptSessionManager * @return Our ScriptSessionManager */ protected ScriptSessionManager getScriptSessionManager() { if (sessionManager == null) { sessionManager = container.getBean(ScriptSessionManager.class); } return sessionManager; }
/** * Look up the Handler associated with the URL in the named URL property. * F ex supply the property name "engineHandlerUrl" to look up EngineHandler. * * @param container The container to look into * @param property a URL property name known by the container (usually * declared in defaults.properties) * @return the Handler registered on the URL */ public static Handler getHandlerForUrlProperty(Container container, String property) { String registeredHandlerUrl = (String) container.getBean(property); return (Handler) container.getBean("url:" + registeredHandlerUrl); }
/** * Get an boolean setting from the Container. * @param container The container to look into * @param name The name of the setting to investigate * @param defaultValue The value to return if none is given * @return The value of the setting as an boolean, or the defaultValue if the * setting is empty or not convertible. */ public static boolean getBooleanSetting(Container container, String name, boolean defaultValue) { Object value = container.getBean(name); if (value == null) { return defaultValue; } return Boolean.parseBoolean(value.toString()); }
/** * Internal method to allow us to get the Builder from which we will get * created objects. Do NOT call this method from outside of DWR. * This function should <em>only</em> be called during startup. * our Container Builder from. */ public T attach(Container container) { this.builder = container.getBean(created); return builder.attach(container); }
public String getContextPath() { UrlProcessor urlProcessor = container.getBean(UrlProcessor.class); return urlProcessor.getContextPath(); }
/** * Clean up the current thread when {@link #outOfContainerInit()} has been * called. * @param container The container created by {@link #outOfContainerInit()}. */ public static void outOfContainerDestroy(Container container) { WebContextBuilder webContextBuilder = container.getBean(WebContextBuilder.class); if (webContextBuilder != null) { webContextBuilder.disengageThread(); } }
public void engageThread(Container container, HttpServletRequest request, HttpServletResponse response) { try { ServletConfig servletConfig = container.getBean(ServletConfig.class); ServletContext servletContext = container.getBean(ServletContext.class); WebContext ec = new DefaultWebContext(container, request, response, servletConfig, servletContext); engageThread(ec); } catch (Exception ex) { log.fatal("Failed to create an ExecutionContext", ex); } }
public PageScriptSessionFilter(ServerContext serverContext, String page) { PageNormalizer pageNormalizer = serverContext.getContainer().getBean(PageNormalizer.class); this.page = pageNormalizer.normalizePage(page); }
/** * Annotations must not break 1.3, so we use reflection to create an * <code>org.directwebremoting.annotations.AnnotationsConfigurator</code> * and the catch all sorts of random exceptions for the benefit of * Websphere. * @param container The container to configure * @return true if the configuration worked. */ public static boolean configureFromAnnotations(Container container) { Object data = container.getBean("classes"); if (null != data) { Configurator configurator = new AnnotationsConfigurator(); configurator.configure(container); Loggers.STARTUP.debug("Java5 AnnotationsConfigurator enabled"); return true; } return false; }
public static String sanitizeErrorMessage(String errorMessage) { boolean debug = false; Object debugVal = WebContextFactory.get().getContainer().getBean("debug"); if (debugVal != null) { debug = LocalUtil.simpleConvert(debugVal.toString(), Boolean.class); } if (debug) { return "null /* " + errorMessage.replace("*/", "* /") + " */"; } else { return "null"; } } }
/** * Add an SCA service to be added to the DWR runtime */ public void addService(RuntimeEndpointReference epr) { CreatorManager creatorManager = (CreatorManager)getContainer().getBean(CreatorManager.class.getName()); addService(creatorManager, epr); serviceRefs.put(epr.getReference().getName(), epr); }
@Override public void destroy() { webContextBuilder = container.getBean(WebContextBuilder.class); if (webContextBuilder != null) { webContextBuilder.engageThread(container, null, null); } container.destroy(); if (webContextBuilder != null) { webContextBuilder.disengageThread(); } super.destroy(); }
/** * Generates and returns a new unique id suitable to use for the * CSRF session cookie. This method is itself exempted from CSRF checking. */ public String generateId() { WebContext webContext = WebContextFactory.get(); // If the current session already has a set DWRSESSIONID then we return that HttpServletRequest request = webContext.getHttpServletRequest(); HttpSession sess = request.getSession(false); if (sess != null && sess.getAttribute(ATTRIBUTE_DWRSESSIONID) != null) { return (String) sess.getAttribute(ATTRIBUTE_DWRSESSIONID); } // Otherwise generate a fresh ID IdGenerator idGenerator = webContext.getContainer().getBean(IdGenerator.class); return idGenerator.generate(); }
@Override public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { try { webContextBuilder.engageThread(container, request, response); UrlProcessor processor = container.getBean(UrlProcessor.class); processor.handle(request, response); } finally { webContextBuilder.disengageThread(); } }
/** * Something has published to the client side 'hub' and we're getting to * know about it. * @param topic The topic that has been published to * @param data The published data */ public void publish(String topic, RealRawData data) { WebContext webContext = WebContextFactory.get(); ConverterManager converterManager = webContext.getContainer().getBean(ConverterManager.class); Hub hub = HubFactory.get(); MessageEvent event = new DefaultMessageEvent(hub, converterManager, data); hub.publish(topic, event); }
/** * Process the @Filter annotation * @param filterAnn The filter annotation * @param name The Javascript name of the class to filter * @param container The IoC container to configure */ protected void processFilter(Filter filterAnn, String name, Container container) { Map<String, String> filterParams = getParamsMap(filterAnn.params()); AjaxFilter filter = LocalUtil.classNewInstance(name, filterAnn.type().getName(), AjaxFilter.class); if (filter != null) { LocalUtil.setParams(filter, filterParams, null); AjaxFilterManager filterManager = container.getBean(AjaxFilterManager.class); filterManager.addAjaxFilter(filter, name); } }