Preliminary knowledge of WEBX 1:http://www.cnblogs.com/lddbupt/p/5547189.html
The WEBX framework is responsible for completing a series of foundational tasks. such as system initialization and response requests .
System initialization: Initializes the spring container and initializes the log system.
Response Request: Enhance the function of request/response/session, provide pipeline process processing mechanism, exception handling, development mode.
The WEBX framework provides a scalable, extensible basic framework for processing Web requests. The basic functionality it provides is in fact a requirement for every web framework. The WEBX framework provides a solid foundation for further implementation of the Web framework.
Initializes a cascade spring container with WEBX initialization
The WEBX framework will be responsible for creating a cascading set of spring container structures. The spring container created by WEBX is fully compatible with the containers created by spring MVC and can be used by all web frameworks that use the spring framework as the basis.
The Webxcontextloaderlistener is derived from the Contextloaderlistener in spring, which can be used to initialize the spring container instead.
The WEBX framework will automatically search /WEB-INF for the XML configuration file under the directory and create the following cascading spring container.
Note: If you do not want to divide your application into multiple small application modules, then you need to configure at least one Small application module (sub-container).
Initializing the log system
The WEBX framework uses SLF4J as its log framework. Therefore the WEBX framework theoretically supports all log systems. So far, however, it contains only the initialization modules for both the log4j and logback log systems.
LogConfiguratorListenerAutomatically selects the appropriate log profile based on the log system that your current app relies on (typically configured in Maven project).
- Assuming your application relies on the Logback jar package, listener will look up
/WEB-INF/logback.xml and use it to initialize the Logback;
- If your app relies on log4j jar packages, listener will also be smart enough to look for
/WEB-INF/log4j.xml configuration files.
- If the above configuration file does not exist, listener will use the default configuration--print the logs on the console.
- Listener supports the substitution of placeholders in the configuration file.
- Listener supports simultaneous initialization of multiple log systems.
WEBX Response Request
When the WEBX framework receives a request from the web, it encapsulates it into an easier-to-use RequestContext object (enhanced request, response, session function), and then, to the sub-application, The pipeline of the corresponding sub-application is called for further processing.
If an exception occurs in the above procedure, the WEBX framework processing exception is triggered.
Enhance the function of request, response, session
Request contexts service. Use HttpServletRequestWrapper and HttpServletResponseWrapper package the request and response objects to achieve new functionality.
Request contexts all functions are configurable and extensible-it is a springext-based extension mechanism.
The added functionality of Request contexts is transparent to all applications that are based on the standard Servlet API-these applications do not need to know the existence of these extensions at all. For example, if you have an enhanced session framework configured in the request contexts service, all applications that get session through the standard Servlet API will get new functionality.
[Inject special objects]
In this example, the LoginAction class can be a singleton. In general, you cannot inject the object of the request scope into the singleton scope object . but you can HttpServletRequest inject, HttpServletResponse and HttpSession object into the Singleton object . Why is it? It turns out that theRequest contexts service specifically handles these common objects and transforms them into singleton objects.
Without this feature, we would have to configure the above example to LoginAction request scope. This increases the complexity of the system and reduces performance exponentially. Instead LoginAction , it is set to Singleton, which is initialized once at system startup and can be referenced quickly in the future.
Reference documents
http://www.openwebx.org/
First Acquaintance WEBX 2