DWR's analysis DWRServlet category

sponsored links
org.directwebremoting.servlet.DwrServlet be divided into three parts, that is, the three main methods: init; doGet; doPost

1, init, initialize.
DWR containers for internal Servelet a configuration container, the container load dwr mapping information.

public void init (ServletConfig servletConfig) throws ServletException
super.init (servletConfig);
ServletContext servletContext = servletConfig.getServletContext ();

/ / SetupLogging () only needed for servlet logging if commons-logging is unavailable
/ / LogStartup () just outputs some version numbers
Log initialization begin
StartupUtil.logStartup (servletConfig);

/ / Create and setup a DefaultContainer
DWR for a Servelet internal configuration container vessel, the vessel loaded with relevant information indicate dwr.
container = ContainerUtil.createAndSetupDefaultContainer (servletConfig);

StartupUtil.initContainerBeans (servletConfig, servletContext, container);
webContextBuilder = container.getBean (WebContextBuilder.class);

ContainerUtil.prepareForWebContextFilter (servletContext, servletConfig, container, webContextBuilder, this);
ContainerUtil.publishContainer (container, servletConfig);
ContainerUtil.configureContainerFully (container, servletConfig);
catch (ExceptionInInitializerError ex)
log.fatal ( "ExceptionInInitializerError. Nested exception:", ex.getException ());
throw new ServletException (ex);
catch (Exception ex)
log.fatal ( "DwrServlet.init () failed", ex);
throw new ServletException (ex);
if (webContextBuilder! = null)
webContextBuilder.unset ();

The aspect in detail:
init () call
createAndSetupDefaultContainer () call
setupDefaultContainer (defaultContainer, servletConfig)
Call the following steps
1) setupDefaults (container);
Include: containers related to configuration management tool set, that is, to achieve a number of interfaces. Fine this way, when the containers have required a lot of interface functions, to make all of these interfaces hint, and set of implementation can be configured
container.addImplementation (AccessControl.class, DefaultAccessControl.class);
/ / Mapping handlers to URLs, the path configuration
createUrlMapping (container, "/ index.html", IndexHandler.class, "indexHandlerUrl");
/ / Read configuration servlet property
2) setupFromServletConfig (container, servletConfig);

Additional treatment 1) in many types of election
3) resolveMultipleImplementations (container, servletConfig);

Which the use of a common type compressor yui
【YUI Compressor using Javascript and CSS compression
YUI Compressor is a tool for the preparation of the use of Java, Java version required greater than or equal to 1.4.
Introduction of job:
Mainly to remove redundant blank, including spaces, line breaks, tabs.
For Javascript, also uses a variable name of the method to shorten the compressed file, that is, to ensure code correctness in the case of only the variable name in a string of characters to replace, or two, three characters, try a short short.
For CSS, also used to optimize the value of 0 the value of the property that the color values Optimize files.
CSS Optimization CSSTidy function than the weak. CSSTidy also supports the merger of some of the relevant property. 】
/ / Instrument configuration set load, appear, check
4) container.setupFinished ();
Initialize bean container contents, including the system default? ? ?

2, doGet
The actual call doPost, seen here under the best study of the servlet's doGet method and the difference between doPost
protected void doGet (HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException
doPost (req, resp);

3, doPost
In the project, there is a sample Dynamically Text, address http://localhost:5050/dwr/simpletext/index.html, when click button, is in fact triggered the following methods org.directwebremoting.servlet.DwrServlet .
protected void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
webContextBuilder.set (request, response, getServletConfig (), getServletContext (), container);

UrlProcessor processor = container.getBean (UrlProcessor.class);
processor.handle (request, response);
webContextBuilder.unset ();
  • del.icio.us
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb

Related Posts of DWR's analysis DWRServlet category

  • and analysis of the use of DWR

    1. Download dwr.jar, to add it to WEB-INF/lib directory 2. Modify web.xml file, add the mapping DWRServlet <servlet> <servlet-name> dwr-invoker </ servlet-name> <servlet-class> org.directwebremoting.servlet.DwrServlet </ se ...

  • DWR's Hello world

    Add a package to dwr.jar project, and modifying the web.xml file, add: 2 in the web-inf following documents dwr.xml add. 3 Medium <head> the page add: 4 DWR add the implementation class

  • Hibernate access picture sample

    General web users to upload picture at treatment would normally uses two types of strategies: First, put directly into the picture in the database Blob field; II database are stored only at the picture on the path of the server information?, Pictures stor

  • hibernate query cache

    hibernate query cache Query cache is cached result set of common property On the entity object cache only the result set id Query cache life cycle, when the associated table happened to amend, then the query cache of the life cycle of The End Query cache

  • hibernate how to store binary, image and other major fields.

    model categories: reportByte binary type for the database fields. public class PfReportStyle implements java.io.Serializable , Cloneable { // Fields /** * */ private static final long serialVersionUID = 1L; private Long id; private byte[] reportByte; // C

  • hibernate study of the second

    Persistence of three main points: 1, a statement for persistent fields accessors (accessors) and whether the variable signs (mutators) Property statement is not necessarily required for the public's. Hibernate can be default, protected or private ...

  • hibernate (jpa) composite primary key annotation statement Ways

    In the design of the database tables are designed with a composite primary key of the table, that table's record by more than one field joint identification, such as: Table CREATE TABLE TB_HOUR_DATA ( STAT_DATE DATE NOT NULL, PATH_ID NUMBER(20) NOT NULL,

  • jboss ejb3 Message Driven Bean

    Super Medium ejb hate. . . . . . . . . . . . . . . . . . . ================================================ To configure a Message Driven Bean in a different application server parameters are not the same. Currently only passed the test jboss. Message Dri

  • WebQQ, ExtJs + Servlet + Hibernate + Spring implementation

    Code for the development of boredom when using ExtJs + Servlet + hibernate (Ant + xdoclet generate HBM files) + spring implementation, Pure whim, but implementation has been more than chat, group chat, what's not achieve, nor how to consider the perfo

  • hibernate generic generic DAO

    package org.lzpeng.dao; import java.io.Serializable; import java.util.List; import org.hibernate.Criteria; import org.hibernate.Query; import org.hibernate.criterion.Criterion; import org.springside.modules.orm.hibernate.Page; /** * * @version 2009-1-10 *

blog comments powered by Disqus
Recent Entries
Tag Cloud
Random Entries