Lightweight Container

xiaoxiao2021-03-06  41

Lightweight Container Analysis Preface Currently, the web-based MVC framework is free to prosper in J2EE. TTS (www.theserverside.com) There will be a new MVC framework for almost one or two weeks. Better MVC frame, old style with struts, webwork. Emerging MVC frames have Spring MVC, TapeStry, JSF, etc. Most of these are famous teams, and there are also some edge teams' works, which are quite excellent, such as DINAMICA, VRAPTOR, etc. These frameworks provide better hierarchical separation capabilities. By providing a good MVC separation, by providing some ready-made auxiliary libraries, production efficiency is also promoted. However, Web layer knowledge solves the small part of our question, keeping Thin Web Layer is a very worthwhile and important strategy, which should only be responsible for interactiveness and response logic with customers, and do not involve how system business features are implemented and maintained. The complexity of the system often is also determined by our business model, so the architecture of the Business layer is often a very important role. About the architecture of the Business layer has a consensus, that is, our business object (Component, Service ...) requires a good framework to manage, safe, transaction, logic division, code reuse, extension, and component life cycles. Wait. Fortunately, we can use the container to solve these problems (from the existence form, the container is also a framework). 1 Basic Concept 1.1 Container Container is a set of managers that provide a series of services, as long as you meet the service requirements of the container (specification), the container allows you to use management services within the range. As early as the Web popular, HTTP Container provides us with the ability to parse HTML, so that our HTML code can be released to the Internet through the HTTP protocol. With the promotion of web applications, the development of dynamic languages, HTTP containers can gradually use designated Interface to explain special pieces in special files, such as PHP, ASP, JSP, and more. 1.2 Lightweight container "Lightweight Container" is increasingly becoming one of the discussion of the Java world. So what is "lightweight" container? In you browsing the recent article or blog, you will not intend to mention "LightWeigh Containter", with the most appearance of this word is "IOC", "dependencies inject", "AOP", etc.. Since it is "light", it is the comparative "heavy". The typical representative of "heavy" is EJB, EJB provides a series of "heavyweight" enterprise services, and allows you to develop components that can be well-integrated EJB containers, such as JTA, etc. So since there is an EJB container, why still need "lightweight"? People who have EJB experience deeply feel: 1), deploy complex, slow operation 2), inner service, slow 3), rule more Small space 4), it is difficult to test (debug) ... The emergence of "lightweight container" is committed to solving these problems and integrating new models, providing more flexible services. Lightweight containers do not support distributed environments, but not all programs require this service. 2 Lightweight container features 2.1 Packages facing the package, the component particle size has always been the biggest problem in SA (Software Architecture).

According to the EJB model, the EJB component allows us to encapsulate business components into coarse granular business components. Lightweight containers can define a finer granity component, even this component has only one object. The decoupling mode represented by Dependency Injection, Di can make the component do not depend on the API of the container (running environment). Di as the pipeline of the container, assumes the role of the middle, allowing the user (Component) and the provider unrelated. For what particle size to design business components, this is determined by the specific needs of the business, and any framework can't help you. And the technical support for lightweight containers is also absolutely letting you have. 2.2 Components face components, the real components are like U-Disk in your hand, you can enjoy its feature on the USB. Lightweight containers have initiative to manage the container by reverse control (Inversion of Control, IOC) and manages the inserted components. As long as the component meets the standard, it can be managed by lightweight container. 2.3Running Anywhere Face Running Anywhere, lightweight container allows components to exist in Pojo (Plain Old Java Object), as long as you have Java.exe, you can run it. In this way, the component is at all, an independent functional integrated class, which does not require a container to implement test behavior. The above three points, the benefits of bringing us are not only the case, but we will benefit from all aspects of reuse, productivity, test (quality), transplantability. 3 The status of lightweight containers Currently, the lightweight container has been widely recognized in the Open Source range, and as the basis of the next generation J2EE architecture, there is an advantage of being comparable. Currently, there are existing lightweight container frames (see table below), there are most part of the Open Source community, which gives us a threshold for this technology. Sequence vessel name URL domestic / foreign usage 1Spring frameworkhttp://www.springframework.org/ Wide evaluation of 2PicoContainerhttp: //www.picocontainer.org/ Someone is used, the evaluation is very good 3Appfusehttp://raibledesigns.com/ Wiki / Some people use, all the frameworks, which can be integrated, 4hivemindhttp: //jakarta.apache.org/hivemind/, evaluation, general 5AVALONHTTP: //avalon.apache.org/ The project has stopped 6nanocontainehttp: //www.nanocontainer.org/ Estimated people in China, few 7PEAPOD http://www.peapod.org/ Estimated people in China to use rarely 8carbonhttp: //carbon http: //carbon.sourceforge.net/ Estimated very few people in China 9EXCalibur http://excalibur.apache.org/index.html Estimated people in China very much 10Gravity http://gravity.dev.java.net Estimated very few people in China

List of lightweight containers currently

The above PicoContainer as the Type3 (IOC) of the Chuner and the Spring IoC container has become the leader in this. The IOC container has brought a far-reaching impact on traditional Container (AS EJB).

4 Spring Framework 4.1 Background

SpringFramework is actually concrete implementation of design ideas described in Expert One-ON-One J2EE Design AndDevelopy. In One-ON-One book, Rodjohnson advocates the design idea of ​​J2EE pragmatism and provides a preliminary development framework implementation (Interface21 development package). Springframework is a more comprehensive and concrete manifestation of this idea. Rod Johnson has further transformed and expanded on the foundation of the Interface21 development package, making it a more open, clear, comprehensive, and efficient development framework. 4.2 Overview

Spring contains many functions and features and is well organized in the seven modules shown below.

Spring framework overview

The Beans package is the most basic part of the framework, and provides the dependency incjection feature to make you manage the bean tolerance. The foundation concept here is BeanFactory, which provides Factory mode to eliminate the needs of programmatic single examples and allow you to separate the configuration and description of dependencies from actual logic. Construction of the Context package on the Beans package, providing a frame-type Bean access method, some like JNDI registration. The Context package is characterized from the Beans package and adds a message, event propagation, resource loading, and transparent creation of Context, such as through the servlet container. The DAO package provides an abstract layer of JDBC that eliminates the error code written by a lengthy JDBC code and parsing a database vendor. This package also provides a way to achieve programming and declarative transaction management, not just a class that implements a specific interface, but is against all POJOs. The ORM package is a popular relationship - object mapping provides an integrated layer, including JDO, Hibernate, and Ibatis. With the ORM package, you can use these O / R mappings to use these O / R mappings, such as simple declarative transactions mentioned earlier. Spring's AOP package provides aspective-oriented aspects of aspects of AOP alliance, allowing you to define, such as method interceptors and cut points to cleanly enable code decoupling from logically. With source-level metadata features, you can merge various behavior information into your code, a bit like .NET's Attribute. Spring's web pack provides basic web-oriented comprehensive features, such as Multipart feature, initializing the Context of the Servlet listener and the web-oriented Applicatin Context. When Spring is used with WebWork or Struts, this package can be combined with other frameworks. Spring's Web MVC package provides Model-View-Controller implementation for web applications. Spring's MVC implementation is not just an implementation, it provides a Domain Model code and a clear separation of Web Form, which allows you to use all other features of the Spring framework such as check.

4.3 Benefits of using Spring -Spring can effectively organize your intermediate objects, whether or not you choose to use EJB. If you only use Struts or other API special Framework for J2EE, Spring is committed to resolving the remaining issues. -Spring can eliminate excessive use of Singleton in many projects. This is a big problem that reduces the system's measurable trissature and object-oriented level. - Treat configuration files in different applications and projects, Spring can eliminate the needs of attribute files in a variety of custom formats. Once I have to find a certain type of property item or system attribute, I have to read Javadoc or even source coding for this? With Spring, you just need to see the JavaBean property of the class. Inversion of Control's use helps this simplification. - By reducing the interface of interfaces rather than classifying classes, Spring can facilitate developing good programming habits. -Spring is designed to let the apps that use it as little depends on his APIS. Most business objects in Spring applications do not depend on Spring. - Applications built using Spring are easy to unit test. -Spring enables EJB's use into an implementation choice, not an inevitable choice for the application architecture. You can choose to use Pojos or Local EJBS to traffic interface, but will not affect the call code. -Spring helps you solve many problems without using EJB. Spring provides an EJB replacement that is suitable for many web applications. -Spring can use AOP to provide declarative transaction management without passing the EJB container, if you only need to deal with a single database, you need a JTA implementation. -Spring provides a consistent framework for data access, whether it is JDBC or an O / R mapping product (such as hibernate). 5 Conclusion This paper introduces the concept, advantages, and the currently existing and popular containers, and finally introduces the Spring framework. The purpose is to provide guidance to the selection of lightweight containers, provide entry for the study of the Spring framework recommended for the author. If you want to learn further, please refer to the link of the reference information section of this article. 6 References - Perspective Lightweight Container http://spring.jActiongroup.net/viewtopic.php?t=825 - Lightweight J2EE Business Layer Architecture Design Guide http://blog.blogchina.com/category.10549. HTML -SPRING Development Guide (V0.8) http://www.xiaxin.net/spring_dev_guide.rar -introducing to Spring Framework http://spring.jactiongroup.net/viewtopic.php?t=453 -spring - Java / J2EE Application Framework http://www.jactiongroup.net/reference/html/index.html

转载请注明原文地址:https://www.9cbs.com/read-70499.html

New Post(0)