001: /*
002: * Copyright 2005 Joe Walker
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.directwebremoting.impl;
017:
018: import java.io.IOException;
019: import java.util.ArrayList;
020: import java.util.Enumeration;
021: import java.util.HashMap;
022: import java.util.List;
023: import java.util.Map;
024: import java.util.StringTokenizer;
025:
026: import javax.servlet.ServletConfig;
027: import javax.servlet.ServletContext;
028: import javax.servlet.http.HttpServlet;
029: import javax.xml.parsers.ParserConfigurationException;
030:
031: import org.apache.commons.logging.Log;
032: import org.apache.commons.logging.LogFactory;
033: import org.directwebremoting.Container;
034: import org.directwebremoting.ServerContext;
035: import org.directwebremoting.ServerContextFactory;
036: import org.directwebremoting.HubFactory.HubBuilder;
037: import org.directwebremoting.ServerContextFactory.ServerContextBuilder;
038: import org.directwebremoting.WebContextFactory.WebContextBuilder;
039: import org.directwebremoting.annotations.AnnotationsConfigurator;
040: import org.directwebremoting.dwrp.DefaultConverterManager;
041: import org.directwebremoting.dwrp.HtmlCallMarshaller;
042: import org.directwebremoting.dwrp.PlainCallMarshaller;
043: import org.directwebremoting.extend.AccessControl;
044: import org.directwebremoting.extend.AjaxFilterManager;
045: import org.directwebremoting.extend.Compressor;
046: import org.directwebremoting.extend.Configurator;
047: import org.directwebremoting.extend.ContainerAbstraction;
048: import org.directwebremoting.extend.ContainerConfigurationException;
049: import org.directwebremoting.extend.ConverterManager;
050: import org.directwebremoting.extend.Creator;
051: import org.directwebremoting.extend.CreatorManager;
052: import org.directwebremoting.extend.DebugPageGenerator;
053: import org.directwebremoting.extend.DownloadManager;
054: import org.directwebremoting.extend.DwrConstants;
055: import org.directwebremoting.extend.Handler;
056: import org.directwebremoting.extend.PageNormalizer;
057: import org.directwebremoting.extend.Remoter;
058: import org.directwebremoting.extend.ScriptSessionManager;
059: import org.directwebremoting.extend.ServerLoadMonitor;
060: import org.directwebremoting.servlet.AboutHandler;
061: import org.directwebremoting.servlet.AuthHandler;
062: import org.directwebremoting.servlet.DownloadHandler;
063: import org.directwebremoting.servlet.DwrWebContextFilter;
064: import org.directwebremoting.servlet.EngineHandler;
065: import org.directwebremoting.servlet.GiHandler;
066: import org.directwebremoting.servlet.HtmlCallHandler;
067: import org.directwebremoting.servlet.HtmlPollHandler;
068: import org.directwebremoting.servlet.IndexHandler;
069: import org.directwebremoting.servlet.InterfaceHandler;
070: import org.directwebremoting.servlet.MonitorHandler;
071: import org.directwebremoting.servlet.PathConstants;
072: import org.directwebremoting.servlet.PlainCallHandler;
073: import org.directwebremoting.servlet.PlainPollHandler;
074: import org.directwebremoting.servlet.TestHandler;
075: import org.directwebremoting.servlet.UrlProcessor;
076: import org.directwebremoting.servlet.UtilHandler;
077: import org.directwebremoting.servlet.WebworkUtilHandler;
078: import org.directwebremoting.util.LocalUtil;
079: import org.xml.sax.SAXException;
080:
081: /**
082: * An abstraction of all the common servlet operations that are required to host
083: * a DWR service that depends on the servlet spec.
084: * It would be good to have a base class for all servlet operations, however
085: * lack of MI prevents us from doing this.
086: * @author Joe Walker [joe at getahead dot ltd dot uk]
087: */
088: public class ContainerUtil {
089: /**
090: * A combination of {@link #createDefaultContainer(ServletConfig)} and
091: * {@link #setupDefaultContainer(DefaultContainer, ServletConfig)}.
092: * @param servletConfig The source of init parameters
093: * @return A setup implementation of DefaultContainer
094: * @throws ContainerConfigurationException If the specified class could not be found or instantiated
095: */
096: public static Container createAndSetupDefaultContainer(
097: ServletConfig servletConfig)
098: throws ContainerConfigurationException {
099: Container container;
100:
101: try {
102: String typeName = servletConfig
103: .getInitParameter(Container.class.getName());
104: if (typeName == null) {
105: container = new DefaultContainer();
106: } else {
107: log.debug("Using alternate Container implementation: "
108: + typeName);
109: Class<?> type = LocalUtil.classForName(typeName);
110: container = (DefaultContainer) type.newInstance();
111: }
112:
113: if (container instanceof DefaultContainer) {
114: DefaultContainer defaultContainer = (DefaultContainer) container;
115: setupDefaultContainer(defaultContainer, servletConfig);
116: }
117: } catch (Exception ex) {
118: throw new ContainerConfigurationException(ex);
119: }
120:
121: return container;
122: }
123:
124: /**
125: * Create a {@link DefaultContainer}, allowing users to upgrade to a child
126: * of DefaultContainer using an {@link ServletConfig} init parameter of
127: * <code>org.directwebremoting.Container</code>. Note that while the
128: * parameter name is the classname of {@link Container}, currently the only
129: * this can only be used to create children that inherit from
130: * {@link DefaultContainer}. This restriction may be relaxed in the future.
131: * Unlike {@link #setupDefaultContainer(DefaultContainer, ServletConfig)},
132: * this method does not call any setup methods.
133: * @param servletConfig The source of init parameters
134: * @return An un'setup' implementation of DefaultContainer
135: * @throws ContainerConfigurationException If the specified class could not be found
136: * @see ServletConfig#getInitParameter(String)
137: * @deprecated Use {@link #createAndSetupDefaultContainer(ServletConfig)}
138: */
139: @Deprecated
140: public static DefaultContainer createDefaultContainer(
141: ServletConfig servletConfig)
142: throws ContainerConfigurationException {
143: try {
144: String typeName = servletConfig
145: .getInitParameter(Container.class.getName());
146: if (typeName == null) {
147: return new DefaultContainer();
148: }
149:
150: log.debug("Using alternate Container implementation: "
151: + typeName);
152: Class<?> type = LocalUtil.classForName(typeName);
153: return (DefaultContainer) type.newInstance();
154: } catch (Exception ex) {
155: throw new ContainerConfigurationException(ex);
156: }
157: }
158:
159: /**
160: * Setup a {@link DefaultContainer}.
161: * Using {@link #createDefaultContainer(ServletConfig)} followed by
162: * {@link #setupFromServletConfig(DefaultContainer, ServletConfig)} before
163: * calling {@link DefaultContainer#setupFinished()}.
164: * @param container The container to configure
165: * @param servletConfig The source of init parameters
166: * @throws ContainerConfigurationException If we can't use a bean
167: */
168: public static void setupDefaultContainer(
169: DefaultContainer container, ServletConfig servletConfig)
170: throws ContainerConfigurationException {
171: setupDefaults(container);
172: setupFromServletConfig(container, servletConfig);
173: resolveContainerAbstraction(container, servletConfig);
174: container.setupFinished();
175: }
176:
177: /**
178: * We need to decide which {@link ContainerAbstraction} should be the
179: * default for this {@link Container}, also we should prepare the default
180: * {@link ServerLoadMonitor}.
181: * @param container The container to configure
182: * @param servletConfig Information about the environment
183: * @throws ContainerConfigurationException If we can't use a bean
184: */
185: @SuppressWarnings("unchecked")
186: public static void resolveContainerAbstraction(
187: DefaultContainer container, ServletConfig servletConfig)
188: throws ContainerConfigurationException {
189: String abstractionImplNames = container
190: .getParameter(ContainerAbstraction.class.getName());
191: for (String abstractionImplName : abstractionImplNames
192: .split(" ")) {
193: try {
194: Class<ContainerAbstraction> abstractionImpl = (Class<ContainerAbstraction>) Class
195: .forName(abstractionImplName);
196: ContainerAbstraction abstraction = abstractionImpl
197: .newInstance();
198: if (abstraction.isNativeEnvironment(servletConfig)) {
199: container
200: .addImplementation(
201: ContainerAbstraction.class,
202: abstractionImpl);
203:
204: String loadMonitorImplName = container
205: .getParameter(ServerLoadMonitor.class
206: .getName());
207: if (loadMonitorImplName == null) {
208: Class<? extends ServerLoadMonitor> loadMonitorImpl = abstraction
209: .getServerLoadMonitorImplementation();
210: container.addImplementation(
211: ServerLoadMonitor.class,
212: loadMonitorImpl);
213: }
214:
215: return;
216: }
217: } catch (Exception ex) {
218: throw new ContainerConfigurationException(
219: "Exception while loading ContainerAbstraction called : "
220: + abstractionImplName, ex);
221: }
222: }
223:
224: throw new ContainerConfigurationException(
225: "None of the configured ContainerAbstractions claims isNativeEnvironment=true. Implementations tested: "
226: + abstractionImplNames);
227: }
228:
229: /**
230: * Take a DefaultContainer and setup the default beans
231: * @param container The container to configure
232: * @throws ContainerConfigurationException If we can't use a bean
233: */
234: public static void setupDefaults(DefaultContainer container)
235: throws ContainerConfigurationException {
236: container.addImplementation(AccessControl.class,
237: DefaultAccessControl.class);
238: container.addImplementation(ConverterManager.class,
239: DefaultConverterManager.class);
240: container.addImplementation(CreatorManager.class,
241: DefaultCreatorManager.class);
242: container.addImplementation(UrlProcessor.class,
243: UrlProcessor.class);
244: container.addImplementation(HubBuilder.class,
245: DefaultHubBuilder.class);
246: container.addImplementation(WebContextBuilder.class,
247: DefaultWebContextBuilder.class);
248: container.addImplementation(ServerContextBuilder.class,
249: DefaultServerContextBuilder.class);
250: container.addImplementation(AjaxFilterManager.class,
251: DefaultAjaxFilterManager.class);
252: container
253: .addImplementation(Remoter.class, DefaultRemoter.class);
254: container.addImplementation(DebugPageGenerator.class,
255: DefaultDebugPageGenerator.class);
256: container.addImplementation(PlainCallMarshaller.class,
257: PlainCallMarshaller.class);
258: container.addImplementation(HtmlCallMarshaller.class,
259: HtmlCallMarshaller.class);
260: container.addImplementation(ScriptSessionManager.class,
261: DefaultScriptSessionManager.class);
262: container.addImplementation(PageNormalizer.class,
263: DefaultPageNormalizer.class);
264: container.addImplementation(DownloadManager.class,
265: InMemoryDownloadManager.class);
266: container.addImplementation(Compressor.class,
267: NullCompressor.class);
268:
269: String abstractions = JettyContainerAbstraction.class.getName()
270: + " " + GrizzlyContainerAbstraction.class.getName()
271: + " " + ServletSpecContainerAbstraction.class.getName();
272: container.addParameter(ContainerAbstraction.class.getName(),
273: abstractions);
274:
275: // Mapping handlers to URLs
276: createUrlMapping(container, "/index.html", "indexHandlerUrl",
277: IndexHandler.class);
278: createUrlMapping(container, "/engine.js", "engineHandlerUrl",
279: EngineHandler.class);
280: createUrlMapping(container, "/util.js", "utilHandlerUrl",
281: UtilHandler.class);
282: createUrlMapping(container, "/auth.js", "authHandlerUrl",
283: AuthHandler.class);
284: createUrlMapping(container, "/gi.js", "giHandlerUrl",
285: GiHandler.class);
286: createUrlMapping(container, "/webwork/DWRActionUtil.js",
287: "webworkUtilHandlerUrl", WebworkUtilHandler.class);
288: createUrlMapping(container, "/about", "aboutHandlerUrl",
289: AboutHandler.class);
290: createUrlMapping(container, "/test/", "testHandlerUrl",
291: TestHandler.class);
292: createUrlMapping(container, "/interface/",
293: "interfaceHandlerUrl", InterfaceHandler.class);
294: createUrlMapping(container, "/monitor/", "monitorHandlerUrl",
295: MonitorHandler.class);
296: createUrlMapping(container, "/download/", "downloadHandlerUrl",
297: DownloadHandler.class);
298: createUrlMapping(container, "/call/plaincall/",
299: "plainCallHandlerUrl", PlainCallHandler.class);
300: createUrlMapping(container, "/call/plainpoll/",
301: "plainPollHandlerUrl", PlainPollHandler.class);
302: createUrlMapping(container, "/call/htmlcall/",
303: "htmlCallHandlerUrl", HtmlCallHandler.class);
304: createUrlMapping(container, "/call/htmlpoll/",
305: "htmlPollHandlerUrl", HtmlPollHandler.class);
306: }
307:
308: /**
309: * Creates entries in the {@link Container} so 2 lookups are possible.
310: * <ul>
311: * <li>You can find a {@link Handler} for a URL. Used by {@link UrlProcessor}
312: * <li>You can inject (or lookup) the URL assigned to a {@link Handler}
313: * </ul>
314: * @param container The container to create the entries in
315: * @param url The URL of the new {@link Handler}
316: * @param propertyName The property name (for injection and lookup)
317: * @param handler The class of Handler
318: * @throws ContainerConfigurationException From {@link DefaultContainer#addParameter(String, Object)}
319: */
320: public static void createUrlMapping(DefaultContainer container,
321: String url, String propertyName,
322: Class<? extends Handler> handler)
323: throws ContainerConfigurationException {
324: container.addParameter(PathConstants.URL_PREFIX + url, handler
325: .getName());
326: container.addParameter(propertyName, url);
327: }
328:
329: /**
330: * Take a DefaultContainer and setup the default beans
331: * @param container The container to configure
332: * @param servletConfig The servlet configuration (null to ignore)
333: * @throws ContainerConfigurationException If we can't use a bean
334: */
335: @SuppressWarnings("unchecked")
336: public static void setupFromServletConfig(
337: DefaultContainer container, ServletConfig servletConfig)
338: throws ContainerConfigurationException {
339: Enumeration<String> en = servletConfig.getInitParameterNames();
340: while (en.hasMoreElements()) {
341: String name = en.nextElement();
342: String value = servletConfig.getInitParameter(name);
343: container.addParameter(name, value);
344: }
345: }
346:
347: /**
348: * Make some changes to the ServletContext so {@link DwrWebContextFilter}
349: * can find the Container etc.
350: * @param context The servlet context
351: * @param config The servlet configuration
352: * @param container The container to save in the ServletContext
353: * @param webContextBuilder The WebContextBuilder to save
354: * @param servlet The Servlet to save
355: */
356: public static void prepareForWebContextFilter(
357: ServletContext context, ServletConfig config,
358: Container container, WebContextBuilder webContextBuilder,
359: HttpServlet servlet) {
360: context.setAttribute(Container.class.getName(), container);
361: context.setAttribute(WebContextBuilder.class.getName(),
362: webContextBuilder);
363: context.setAttribute(ServletConfig.class.getName(), config);
364: context.setAttribute(HttpServlet.class.getName(), servlet);
365: }
366:
367: /**
368: * Configure using the system dwr.xml from within the JAR file.
369: * @param container The container to configure
370: * @throws ParserConfigurationException If the config file parse fails
371: * @throws IOException If the config file read fails
372: * @throws SAXException If the config file parse fails
373: */
374: public static void configureFromSystemDwrXml(Container container)
375: throws IOException, ParserConfigurationException,
376: SAXException {
377: DwrXmlConfigurator system = new DwrXmlConfigurator();
378: system.setClassResourceName(DwrConstants.FILE_DWR_XML);
379: system.configure(container);
380: }
381:
382: /**
383: * Configure using the users dwr.xml that sits next in WEB-INF
384: * @param container The container to configure
385: * @throws ParserConfigurationException If the config file parse fails
386: * @throws IOException If the config file read fails
387: * @throws SAXException If the config file parse fails
388: */
389: public static void configureFromDefaultDwrXml(Container container)
390: throws IOException, ParserConfigurationException,
391: SAXException {
392: DwrXmlConfigurator local = new DwrXmlConfigurator();
393: local.setServletResourceName(DwrConstants.DEFAULT_DWR_XML);
394: local.configure(container);
395: }
396:
397: /**
398: * Add configurators from init params to the end of the list of
399: * configurators.
400: * @param container The container to configure
401: * @param servletConfig The source of init parameters
402: * @return true if any Configurators were read
403: * @throws SAXException If the config file parse fails
404: * @throws ParserConfigurationException If the config file parse fails
405: * @throws IOException If the config file read fails
406: */
407: @SuppressWarnings("unchecked")
408: public static boolean configureFromInitParams(Container container,
409: ServletConfig servletConfig) throws IOException,
410: ParserConfigurationException, SAXException {
411: Enumeration<String> en = servletConfig.getInitParameterNames();
412: boolean foundConfig = false;
413: while (en.hasMoreElements()) {
414: String name = en.nextElement();
415: String value = servletConfig.getInitParameter(name);
416:
417: // if the init param starts with "config" then try to load it
418: if (name.startsWith(INIT_CONFIG)) {
419: foundConfig = true;
420:
421: StringTokenizer st = new StringTokenizer(value, "\n,");
422: while (st.hasMoreTokens()) {
423: String fileName = st.nextToken().trim();
424: DwrXmlConfigurator local = new DwrXmlConfigurator();
425: local.setServletResourceName(fileName);
426: local.configure(container);
427: }
428: } else if (name.equals(INIT_CUSTOM_CONFIGURATOR)) {
429: foundConfig = true;
430:
431: try {
432: Configurator configurator = LocalUtil
433: .classNewInstance(INIT_CUSTOM_CONFIGURATOR,
434: value, Configurator.class);
435: configurator.configure(container);
436: log.debug("Loaded config from: " + value);
437: } catch (Exception ex) {
438: log.warn("Failed to start custom configurator", ex);
439: }
440: }
441: }
442:
443: return foundConfig;
444: }
445:
446: /**
447: * Annotations must not break 1.3, so we use reflection to create an
448: * <code>org.directwebremoting.annotations.AnnotationsConfigurator</code>
449: * and the catch all sorts of random exceptions for the benefit of
450: * Websphere.
451: * @param container The container to configure
452: * @return true if the configuration worked.
453: */
454: public static boolean configureFromAnnotations(Container container) {
455: Configurator configurator = new AnnotationsConfigurator();
456: configurator.configure(container);
457:
458: log.debug("Java5 AnnotationsConfigurator enabled");
459: return true;
460: }
461:
462: /**
463: * Allow all the configurators to have a go at the container in turn
464: * @param container The container to configure
465: * @param configurators A list of configurators to run against the container
466: */
467: public static void configure(Container container,
468: List<Configurator> configurators) {
469: // Allow all the configurators to have a go
470: for (Configurator configurator : configurators) {
471: log.debug("** Adding config from " + configurator);
472: configurator.configure(container);
473: }
474: }
475:
476: /**
477: * Run all the default configuration options on a Container
478: * @param container The container to configure
479: * @param servletConfig The source of init parameters
480: * @throws SAXException If the config file parse fails
481: * @throws ParserConfigurationException If the config file parse fails
482: * @throws IOException If the config file read fails
483: */
484: public static void configureContainerFully(Container container,
485: ServletConfig servletConfig) throws IOException,
486: ParserConfigurationException, SAXException {
487: configureFromSystemDwrXml(container);
488: boolean foundConfig = configureFromInitParams(container,
489: servletConfig);
490:
491: // The default dwr.xml file that sits by web.xml
492: boolean skip = Boolean.valueOf(servletConfig
493: .getInitParameter(INIT_SKIP_DEFAULT));
494: IOException delayedIOException = null;
495: if (!foundConfig && !skip) {
496: try {
497: configureFromDefaultDwrXml(container);
498: } catch (IOException ex) {
499: // This is fatal unless we are on JDK5+ AND using annotations
500: delayedIOException = ex;
501: }
502: }
503:
504: if (!configureFromAnnotations(container)) {
505: log.debug("Java5 AnnotationsConfigurator disabled");
506:
507: if (delayedIOException != null) {
508: throw delayedIOException;
509: }
510: }
511: }
512:
513: /**
514: * If helps some situations if people can get at the container by looking
515: * in the servlet context, under some name.
516: * The name is specified in an initParameter.
517: * @param container The container to publish
518: * @param servletConfig Source of initParams to dictate publishing and contexts to publish to
519: */
520: @SuppressWarnings("unchecked")
521: public static void publishContainer(Container container,
522: ServletConfig servletConfig) {
523: ServletContext servletContext = servletConfig
524: .getServletContext();
525:
526: // TODO: Make sense of this
527: // Store this container in the servletContext so long as no-one else did
528: // INIT_PUBLISH_CONTAINER="publishContainerAs" which does not sound like
529: // a logical name. Plus what happens when there is more than one DWR?
530: /*
531: String publishName = servletConfig.getInitParameter(INIT_PUBLISH_CONTAINER);
532: if (publishName != null)
533: {
534: servletContext.setAttribute(publishName, container);
535: }
536: */
537:
538: // Push the container into a list that holds all the known containers
539: List<Container> containers = (List<Container>) servletContext
540: .getAttribute(ATTRIBUTE_CONTAINER_LIST);
541: if (containers == null) {
542: containers = new ArrayList<Container>();
543: }
544: containers.add(container);
545: servletContext.setAttribute(ATTRIBUTE_CONTAINER_LIST,
546: containers);
547:
548: // Update the list of ServerContexts
549: ServerContext serverContext = ServerContextFactory
550: .get(servletContext);
551: String name = servletConfig.getServletName();
552: contextMap.put(name, serverContext);
553: log.debug("Adding to contextMap, a serverContext called "
554: + name);
555:
556: if (contextMap.containsKey(DEFAULT_SERVERCONTEXT_NAME)) {
557: contextMap.remove(DEFAULT_SERVERCONTEXT_NAME);
558: log.debug("Multiple instances of DWR detected.");
559: } else {
560: contextMap.put(DEFAULT_SERVERCONTEXT_NAME, serverContext);
561: }
562: }
563:
564: /**
565: * If there is only once instance of DWR defined in a ServletContext then
566: * we can get at it using this method.
567: * @return The one-and-only ServerContext or null if there are more than 1.
568: */
569: public static ServerContext getSingletonServerContext() {
570: return contextMap.get(DEFAULT_SERVERCONTEXT_NAME);
571: }
572:
573: /**
574: * Get a list of all known Containers for the given {@link ServletContext}
575: * @param servletContext The context in which {@link Container}s are stored.
576: * @return a list of published {@link Container}s.
577: */
578: @SuppressWarnings("unchecked")
579: public static List<Container> getAllPublishedContainers(
580: ServletContext servletContext) {
581: List<Container> containers = (List<Container>) servletContext
582: .getAttribute(ATTRIBUTE_CONTAINER_LIST);
583: if (containers == null) {
584: containers = new ArrayList<Container>();
585: }
586:
587: return containers;
588: }
589:
590: /**
591: * Internal use only.
592: * <p>If we detect that the server is being shutdown then we want to kill
593: * any reverse ajax threads.
594: * @param containers The list of containers to look for ServerLoadMonitors in
595: * @param title What causes this (for debug purposes)
596: */
597: public static void shutdownServerLoadMonitorsInContainerList(
598: List<Container> containers, String title) {
599: if (containers == null || containers.isEmpty()) {
600: log.debug("No containers to shutdown for: " + title);
601: return;
602: }
603:
604: log.debug("Shutting down containers for: " + title);
605: for (Container container : containers) {
606: ServerLoadMonitor monitor = container
607: .getBean(ServerLoadMonitor.class);
608: monitor.shutdown();
609: }
610: }
611:
612: /**
613: * Create a bunch of debug information about a container
614: * @param container The container to print debug information about
615: */
616: public static void debugConfig(Container container) {
617: if (log.isDebugEnabled()) {
618: // Container level debug
619: log.debug("Container");
620: log.debug(" Type: " + container.getClass().getName());
621: for (String name : container.getBeanNames()) {
622: Object object = container.getBean(name);
623:
624: if (object instanceof String) {
625: log.debug(" Param: " + name + " = " + object
626: + " (" + object.getClass().getName() + ")");
627: } else {
628: log.debug(" Bean: " + name + " = " + object + " ("
629: + object.getClass().getName() + ")");
630: }
631: }
632:
633: // AccessControl debugging
634: AccessControl accessControl = container
635: .getBean(AccessControl.class);
636: log.debug("AccessControl");
637: log.debug(" Type: " + accessControl.getClass().getName());
638:
639: // AjaxFilterManager debugging
640: AjaxFilterManager ajaxFilterManager = container
641: .getBean(AjaxFilterManager.class);
642: log.debug("AjaxFilterManager");
643: log.debug(" Type: "
644: + ajaxFilterManager.getClass().getName());
645:
646: // ConverterManager debugging
647: ConverterManager converterManager = container
648: .getBean(ConverterManager.class);
649: log.debug("ConverterManager");
650: log.debug(" Type: "
651: + converterManager.getClass().getName());
652:
653: // CreatorManager debugging
654: CreatorManager creatorManager = container
655: .getBean(CreatorManager.class);
656: log.debug("CreatorManager");
657: log.debug(" Type: " + creatorManager.getClass().getName());
658: for (String creatorName : creatorManager.getCreatorNames()) {
659: Creator creator = creatorManager
660: .getCreator(creatorName);
661: log.debug(" Creator: " + creatorName + " = " + creator
662: + " (" + creator.getClass().getName() + ")");
663: }
664: }
665: }
666:
667: /**
668: * Init parameter: Set a dwr.xml config file.
669: * This is only a prefix since we might have more than 1 config file.
670: */
671: public static final String INIT_CONFIG = "config";
672:
673: /**
674: * Init parameter: Skip reading the default config file if none are specified.
675: */
676: public static final String INIT_SKIP_DEFAULT = "skipDefaultConfig";
677:
678: /**
679: * Init parameter: If we are doing Servlet.log logging, to what level?
680: */
681: public static final String INIT_LOGLEVEL = "logLevel";
682:
683: /*
684: * Init parameter: Should we publish the {@link Container} to the servlet
685: * context, and if so, under what name?
686: */
687: //public static final String INIT_PUBLISH_CONTAINER = "publishContainerAs";
688: /**
689: * Init parameter: If you wish to use a custom configurator, place its
690: * class name here
691: */
692: public static final String INIT_CUSTOM_CONFIGURATOR = "customConfigurator";
693:
694: /**
695: * The name under which we publish all {@link Container}s.
696: */
697: public static final String ATTRIBUTE_CONTAINER_LIST = "org.directwebremoting.ContainerList";
698:
699: /**
700: * We store a single ServerContext in the contextMap under this name.
701: */
702: public static final String DEFAULT_SERVERCONTEXT_NAME = "__default";
703:
704: /**
705: * To enable us to get at a ServerContext if one has been defined or at
706: * all of them if several have been defined
707: */
708: private static final Map<String, ServerContext> contextMap = new HashMap<String, ServerContext>();
709:
710: /**
711: * The log stream
712: */
713: private static final Log log = LogFactory
714: .getLog(ContainerUtil.class);
715: }
|