您好,欢迎来到知库网。
搜索
您的当前位置:首页(整理)毕业设计(论文)外文参考资料及译文

(整理)毕业设计(论文)外文参考资料及译文

来源:知库网


英文原文:

Java is a simple, object-oriented, distributed, interpreted, robust security, structure-neutral, portable, high performance, multithreaded dynamic language. The main advantage of Java language, Java applications across hardware platforms and operating systems for transplant - this is because the JVM is installed on each platform can understand the same byte code. Java language and platform scalability is very strong. At the low end, Java language is the first open standards technology support enterprise one, support the use of XML and Web service can not stride business lines to share information and applications Cheng Xu.

There are three versions of Java platform, which makes software developers, service providers and equipment manufacturers can target specific market development:

1. Java SE form applications. Java SE includes support for Java Web services development classes, and for the Java Platform, Enterprise Edition (Java EE) to provide a basis. Most Java developers use Java SE 5, also known as Java 5.0 or \"Tiger\".

2. Java EE formerly known as J2EE. Enterprise Edition to help develop and deploy portable, robust, scalable and secure server-side Java applications. Java SE Java EE is built on the foundation, which provides Web services, component model, management and communication API, can be used to achieve enterprise-class service-oriented architecture and Web 2.0 applications.

3. Java ME formerly known as J2ME. Java ME devices in mobile and embedded applications running on a robust and flexible environment. Java ME includes flexible user interfaces, robust security model, and many built-in network protocols and networking that can be dynamically downloaded and extensive support for offline applications. Java ME-based application specification only write once and can be used in many devices and can use the native features of each device.

Java language is simple. Java language syntax and the C language and C ++ language is very close, Java discarded the C++, rarely used, hard to understand the characteristics, such as operator overloading, multiple inheritance, the mandatory automatic type conversion. Java language does not use pointers, and provides automated waste collection. Java is an object-oriented language. Java language provides classes, interfaces and inheritance of the original language, for simplicity, only supports single inheritance between classes, but support multiple inheritance between interfaces and support classes and interfaces to achieve between the mechanism (keyword implements) . Java language fully supports dynamic binding, and C ++ language used only for dynamic binding of virtual functions. In short, Java language is a pure object-oriented programming language. Java language is distributed. Java language support for Internet application development, Java's RMI (remote method activation) mechanism is also an important means of developing distributed applications. Java language is robust. Java's strong type system, exception handling, automated waste collection is an important guarantee robust Java programs. Java language is safe. Java is often used in network environment, this, Java provides a security mechanism to prevent malicious code

attacks.

Java language is portable. This portability comes from the architecture neutrality. Java system itself is highly portable. Java language is multi-threaded. In the Java language, the thread is a special object, it must Thread class or the son (Sun) class to create. Java language support simultaneous execution of multiple threads, and provide synchronization mechanisms between threads (keyword synchronized).

Java language features make Java an excellent application of unparalleled robustness and reliability, which also reduced application maintenance costs. Java on the full support of object technology and Java Platform API embedded applications to reduce development time and reduce costs. Java's compile once, run everywhere feature can make it anywhere available to provide an open architecture and multi-platform, low-cost way of transmitting information between. Hibernate Hibernate is a lightweight JDBC object package. It is an independent object persistence framework, and the App Server, and EJB is no necessary link. Hibernate can use JDBC can be used in any occasion, such as Java application, database access code, DAO interface implementation class, or even access the database inside a BMP code. In this sense, Hibernate, and EB is not a category of things that did not exist either-or relationship.

Hibernate and JDBC is a closely related framework, the Hibernate and JDBC driver compatibility, and databases have some relationship, but the Java program and use it, and the App Server does not have any relationship, there was no

compatibility issues. 1614Hibernate provides two Cache, first-level cache is a Session-level cache, which cache belongs to the scope of services. This level of cache by the hibernate managed without the need for intervention under normal circumstances; second-level cache is SessionFactory-level cache, it belongs to the process of range or scope of the cache cluster. This level of cache can be configured and changed, and can be dynamically loaded and unloaded. Hibernate query results also provide a query cache, it depends on the second level cache.

When an application called Session's save (), update (), saveOrUpdate (), get () or load (), and the query interface call list (), iterate () or filter () method, if the Session cache does not exist a corresponding object, Hibernate will put the object to the first level cache. When cleaning the cache, Hibernate objects according to the state of the cache changes to synchronize update the database. Session for the application provides two methods of managing the cache: evict (Object obj): removed from the cache parameters of the specified persistent object. clear (): Empty the cache of all persistent objects.

Hibernate second-level cache strategy general process is as follows:

1) The condition when a query is always issued a select * from table_name where .... (Select all fields) such as SQL statement to query the database, an access to all of the data object.

2) all the data objects to be placed under the ID to the second level cache.

3) When the Hibernate object-based ID to access the data, the first check from the Session a cache; finding out, if the configuration of the secondary cache, then the secondary cache from the investigation; finding out, and then query the database, the results in accordance with the ID into the cache.

4) remove, update and increase the time data, while updating the cache.

Hibernate second against the conditions of the Query Cache.

Hibernate object-relational mapping for the delay and non-delay object initialization. Non-lazy when reading an object and the object will be all read out together with other objects. This sometimes results in hundreds (if not thousands of words) select statement when reading the object implementation. This problem sometimes occurs when using the two-way relationship, often leading to the databases to be read during the initialization phase out. Of course, you can take the trouble to examine each object and other objects of Guanxi, and to the most expensive of the Shan Chu, but in the last, we may therefore lose Le ORM tool this Xiangzai obtained Bian Li.

A cache and secondary cache of comparison: the first level cache second level cache data stored in the form of interrelated persistent objects the object of bulk data cache range of the scope of services, each transaction has a separate first-level cache process range or scope of the cluster, the cache is the same process or cluster to share on all matters within the concurrent access policies because each transaction has a separate first-level cache, concurrency problem

does not occur without the need to provide concurrent access policy will be a number of matters simultaneous access to the same second-level cache data, it is necessary to provide appropriate concurrent access policies, to ensure that a particular transaction isolation level data expiration policies did not provide data expiration policies. Object in a cache will never expire, unless the application explicitly clear the cache or clear a specific object must provide data expiration policies, such as memory cache based on the maximum number of objects, allowing objects in the cache of the most a long time, and allowing the object in the cache the longest idle time of physical memory and hard disk memory storage medium. First of all bulk data objects stored in the memory-based cache, when the number of objects in memory to data expiration policy specified limit, the remaining objects will be written on the hard disk cache. Caching software implementation of the Hibernate Session is included in the realization of the cache provided by third parties, Hibernate provides only a cache adapter (CacheProvider). Used to plug into a particular cache in Hibernate. Way cache enabled applications by as long as the Session interface implementation save, update, delete, data loading and query the database operations, Hibernate will enable first-level cache, the data in the database in the form of an object copied to the cache For batch updates and bulk delete operations, if you do not want to enable first-level cache, you can bypass the Hibernate API, JDBC API directly to perform that operation. Users can type in a single class or a single set of second-level cache size on the configuration. If the instance of the class are frequently read but rarely modified, you can consider using a second-level cache. Only for a class or set of second-level cache is configured, Hibernate will run when an instance of it to the second-level cache. User management means the first level cache of physical media for the

memory cache, because the memory capacity is limited, must pass the appropriate search strategies and retrieval methods to limit the number of objects loaded. Session of the evit () method can explicitly clear the cache a specific object, but this method is not recommended. Second-level cache memory and the physical media can be a hard disk, so the second-level cache can store large amounts of data, data expiration policy maxElementsInMemory property values can control the number of objects in memory. Second-level cache management mainly includes two aspects: Select to use the second-level cache of persistent classes, set the appropriate concurrency strategy: Select the cache adapter, set the appropriate data expiration policies.

One obvious solution is to use Hibernate's lazy loading mechanism provided. This initialization strategy is only invoked in an object-to-many or many to many relationship between its relationship only when read out of the object. This process is transparent to the developer, and only had a few requests for database operations, it will be more obvious performance have open. This will be by using the DAO pattern abstracts the persistence time of a major problem. Persistence mechanisms in order to completely abstract out all of the database logic, including open or closed session, can not appear in the application layer. The most common is the realization of the simple interface of some DAO implementation class to encapsulate the database logic completely. A fast but clumsy solution is to give up DAO mode, the database connection logic to add the application layer. This may be an effective small applications, but in large systems, this is a serious design flaw, preventing the system scalability.

Struts2

Struts2 is actually not a stranger to the Web frameworks, Struts2 is Webwork design ideas as the core, absorb Struts1 advantages, so that the Struts2 is the product of the integration Struts1 and Webwork.

MVC Description: Struts2 WebWork is compatible with the MVC framework Struts1 and since, that the MVC framework on the MVC framework will have to make a brief, limited to a brief, if want to learn more about MVC can view the related knowledge document, or to find a Struts1 books, I believe the above is not rare on the length of MVC. Closer to home, in fact, Java the present situation of these frameworks, its ultimate goal is to contact coupling, whether Spring, Hibernate or the MVC framework, are designed to increase contact with coupling reuse. MVC contact with the coupling between View and Model. MVC consists of three basic parts: Model, View and Controller, these three parts work together to minimize the coupling to increase the scalability of the program and maintainability. Various parts of the implementation technology can be summarized as follows:

1) Model: JavaBean, EJB's EntityBean

2) View: JSP, Struts in TagLib

3) Controller: Struts the ActionServlet, Action

To sum up the advantages of MVC mainly about aspects:

1) corresponds to multiple views can be a model. By MVC design pattern, a model that corresponds to multiple views, you can copy the code and the code to reduce the maintenance amount, if model changes, but also easy to maintain

2) model the data returned and display logic separate. Model data can be applied to any display technology, for example, use the JSP page, Velocity templates, or directly from Excel documents, etc.

3) The application is separated into three layers, reducing the coupling between the layers, providing application scalability

4) The concept of layers is also very effective, because it put the different models and different views together, to complete a different request. Therefore, the control layer can be said to include the concept of user requests permission

5) MVC more software engineering management. Perform their duties in different layers, each layer has the same characteristics of the components is beneficial tool by engineering and production management of program code

Struts2 Introduction: Struts2 Struts1 development appears to come from, but in fact Struts1 Struts2 and design ideas in the framework of the above is very different, Struts2 WebWork's design is based on the core, why not follow the Struts1 Struts2 design ideas After all, Struts1 in the current enterprise applications

market is still very big in the, Struts1 some shortcomings:

1) support the performance of a single layer

2) coupled with the Servlet API serious, this could be the Execute method from the Action Statement which you can see them

3) The code depends Struts1 API, there are invasive, this can be written when the Action class and look out FormBean, Action Struts in Action class must implement

The reason for Struts2 WebWork's design for the core point is the recent upward trend of WebWork and play WebWork not Struts1 above those shortcomings, more MVC design ideas, and more conducive to reuse the code. Based on the above description can be read out, Struts2 architecture and architecture Struts1 very different, Struts1 is to use the ActionServlet as its central processor, Struts2 is using an interceptor (FilterDispatcher) as its central processor, so One benefit is to make Action class and Servlet API was isolated.

Struts2 simple process flow is as follows:

1) browser sends a request

2) the processor to find the corresponding file under struts.xml the Action class to process the request

3) WebWork interceptor chain applications automatically request common functions, such as: WorkFlow, Validation functions

4) If Struts.xml Method configuration file parameters, then call the corresponding Action Method parameters in the Method class method, or call the Execute method to deal with common user request

5) Action class method returns the results of the corresponding response to the browser

Struts2 and Struts1 contrast:

1) Action class impleme achieve the time to achieve any classes and interfaces, while providing a ActionSupport class Struts2, however, not required.

2) Struts1 the Action class is the singleton pattern, must be designed into the thread-safe, Struts2 was generated for each request for an instance

3) Struts1 the Action class dependence and the Servlet API, execute the method from its signature can be seen, execute method has two parameters Servlet HttpServletRequest and HttpServletResponse, Struts2 is not dependent on the Servlet API

4) Struts1 depends on the Servlet API the Web elements, therefore, of Action Struts1 when testing is difficult, it needs with other testing tools, Struts2 in Action

can be as testing a number of other classes as Service Model layer test

5) Struts1 of Action and the View through the ActionForm or its sub-class of data transmission, although there LazyValidationForm this ActionForm appearance, but still can not like the other levels as a simple POJO data transfer, and Struts2 would like expect change becomes a reality

6) Struts1 binding of the JSTL, the preparation of convenience for the page, Struts2 integrates ONGL, you can use JSTL, Therefore, Struts2 is more powerful expression language under

Compared with Struts2 WebWork: Struts2 actually WebWork2.3, however, Struts2 WebWork, or with a little difference:

1) Struts2 IOC no longer support the built-in containers, use Spring's IOC container

2) Struts2 Ajax for Webwork features some of the label to use Dojo to be replaced

Servlet

Servlet is a server-side Java application, platform and protocol independent features that can generate dynamic Web pages. Customer requests to play it (Web browser or other HTTP client) and server response (HTTP server, database or

application) of the middle layer. Servlet Web server is located inside the server-side Java applications started from the command line with the traditional application of different Java, Servlet loaded by the Web server, the Web server must include the Java Virtual Machine to support Servlet.

HTTP Servlet using a HTML form to send and receive data. To create an HTTP Servlet, need to extend the HttpServlet class, the class is a special way to handle HTML forms GenericServlet a subclass. HTML form is

and tag definition. Form typically includes input fields (such as text input fields, check boxes, radio buttons and selection lists) and a button for submitting data. When submitting information, they also specify which server should implement the Servlet (or other program). HttpServlet class contains the init (), destroy (), service () and other methods. Where init () and destroy () method is inherited.

init () method: In the Servlet life period, only run once init () method. It is executed when the server load Servlet. You can configure the server to start the server or the client's first visit to Servlet fashion into the Servlet. No matter how many clients to access Servlet, will not repeat the init (). The default init () method is usually to meet the requirements, but can also use custom init () method to overwrite it, typically the management server-side resources. For example, you may write a custom init () to be used only once a load GIF images, GIF images and improve the Servlet returns with the performance of multiple clients request. Another example is to initialize the database connection. The default init () method sets the Servlet initialization parameters, and use it's ServletConfig object parameter to start the configuration, all covered by init ()

method of the Servlet should call super.init () to ensure that still perform these tasks. In the call to service () method before, make sure you have completed the init () method.

service () method: service () method is the core of Servlet. Whenever a client requests a HttpServlet object, the object of the service () method must be called, and passed to this method a \"request\" (ServletRequest) objects and a \"response\" (ServletResponse) object as a parameter. Already exists in the HttpServlet service () method. The default service function is invoked with the HTTP request method to do the corresponding functions. For example, if the HTTP request method is GET, the default on the call to doGet (). Servlet Servlet support should do HTTP method override function. Because HttpServlet.service () method checks whether the request method calls the appropriate treatment, unnecessary coverage service () method. Just do cover the corresponding method on it.

Servlet response to the following types: an output stream, the browser based on its content type (such as text / HTML) to explain; an HTTP error response, redirect to another URL, servlet, JSP.

doGet () method: When a client through the HTML form to send a HTTP GET request or when a direct request for a URL, doGet () method is called. Parameters associated with the GET request to the URL of the back, and send together with this request. When the server does not modify the data, you should use doGet () method.

doPost () method: When a client through the HTML form to send a HTTP POST request, doPost () method is called. Parameters associated with the POST request as a separate HTTP request from the browser to the server. When the need to modify the server-side data, you should use the doPost () method.

destroy () method: destroy () method is only executed once, that is, stop and uninstall the server to execute the method of Servlet. Typically, the Servlet as part of the process server to shut down. The default destroy () method is usually to meet the requirements, but can also cover it, and typically manage server-side resources. For example, if the Servlet will be accumulated in the run-time statistics, you can write a destroy () method is used in Servlet will not load the statistics saved in the file. Another example is to close the database connection.

When the server uninstall Servlet, it will in all service () method call is completed, or at a specified time interval after the call to destroy () method. Running a Servlet service () method may have other threads, so make sure the call destroy () method, the thread has terminated or completed.

GetServletConfig () method: GetServletConfig () method returns a ServletConfig object, which used to return the initialization parameters and ServletContext. ServletContext interface provides information about servlet environment.

GetServletInfo () method: GetServletInfo () method is an alternative method, which provides information on the servlet, such as author, version, copyright.

When the server calls sevlet of Service (), doGet () and doPost () of these three methods are needed \"request\" and \"response\" object as a parameter. \"Request\" object to provide the requested information, and the \"response\" object to provide a response message will be returned to the browser as a communications channel.

javax.servlet packages in the relevant classes for the ServletResponse and ServletRequest, while the javax.servlet.http package of related classes for the HttpServletRequest and HttpServletResponse. Servlet communication with the server through these objects and ultimately communicate with the client. Servlet through call \"request\" object approach informed the client environment, server environment, information and all information provided by the client. Servlet can call the \"response\" object methods to send response, the response is ready to send back to client

JSP

JavaServerPages (JSP) technology provides a simple and fast way to create a display content dynamically generated Web pages. Leading from the industry, Sun has developed technology related to JSP specification that defines how the server and the interaction between the JSP page, the page also describes the format and syntax.

JSP pages use XML tags and scriptlets (a way to use script code written in Java), encapsulates the logic of generating page content. It labels in various formats (HTML or XML) to respond directly passed back to the page. In this way, JSP pages

to achieve a logical page design and display their separation.

JSP technology is part of the Java family of technologies. JSP pages are compiled into a servlet, and may call JavaBeans components (beans) or EnterpriseJavaBeans components (enterprise beans), so that server-side processing. Therefore, JSP technology in building scalable web-based applications play an important role.

JSP page is not confined to any particular platform or web server. JSP specification in the industry with a wide range of adaptability.

JSP technology is the result of collaboration with industry, its design is an open, industry standards, and support the vast majority of servers, browsers and related tools. The use of reusable components and tags replaced on the page itself relies heavily on scripting languages, JSP technology has greatly accelerated the pace of development. Support the realization of all the JSP to Java programming language-based scripting language, it has inherent adaptability to support complex operations.

Jquery

jQuery is the second prototype followed by a good Javascrīpt framework. Its purpose is: to write less code, do more.

It is lightweight js library (compressed only 21k), which is less than the other js

library which, it is compatible CSS3, is also compatible with all browsers (IE 6.0 +, FF 1.5 +, Safari 2.0 +, Opera 9.0 +).

jQuery is a fast, simple javaScript library, allowing users to more easily deal with HTML documents, events, to achieve animation effects, and provide easy AJAX for interactive web site.

jQuery also has a larger advantage is that it is all documented, and various applications are very detailed, as well as many mature plug-ins available.

jQuery's html page to allow users to maintain separate code and html content, that is, no need to insert in the html inside a pile of js to call the command, and you can just define id.

jQuery is the second prototype followed by a good Javascrīpt framework. On the prototype I use small, simple and understood. However, after using the jquery immediately attracted by her elegance. Some people use such a metaphor to compare the prototype and jquery: prototype like Java, and jquery like a ruby. In fact I prefer java (less contact with Ruby Bale), but a simple jquery does have considerable practical appeal ah! I put the project in the framework jquery as its the only class package. Use the meantime there is also a little bit of experience, in fact, these ideas, in the jquery documentation above may also be speaking, but still it down to stop notes.

译文:

Java是一种简单的,面向对象的,分布式的,解释型的,健壮安全的,结构中立的,可移植的,性能优异、多线程的动态语言。Java 语言的主要好处是,Java 应用程序可以跨硬件平台和操作系统进行移植 —— 这是因为每个平台上安装的 JVM 都可以理解同样的字节码。 Java 语言和平台的可伸缩性非常强。在低端,Java 语言是第一批支持企业开放标准的技术之一,支持使用 XML 和 Web 服务跨业务线共享信息和应用程序。

Java 平台有三个版本,这使软件开发人员、服务提供商和设备生产商可以针对特定的市场进行开发:

1. Java SE 以前称为 J2SE。它允许开发和部署在桌面、服务器、嵌入式环境和实时环境中使用的 Java 应用程序。Java SE 包含了支持 Java Web 服务开发的类,并为 Java Platform,Enterprise Edition(Java EE)提供基础。大多数 Java 开发人员使用 Java SE 5,也称为 Java 5.0 或 “Tiger”。

2. Java EE以前称为 J2EE。企业版本帮助开发和部署可移植、健壮、可伸缩且安全的服务器端 Java 应用程序。Java EE 是在 Java SE 的基础上构建的,它提供 Web 服务、组件模型、管理和通信 API,可以用来实现企业级的面向服务体系结构和 Web 2.0 应用程序。

3. Java ME以前称为 J2ME。Java ME 为在移动设备和嵌入式设备上运行的应用程序提供一个健壮且灵活的环境。Java ME 包括灵活的用户界面、健壮的安全模型、许多内置的网络协议以及对可以动态下载的连网和离线应用程序的丰富支持。基于 Java ME 规范的应用程序只需编写一次,就可以用于许多设备,而且可以利用每个设备的本机功能。

Java语言是简单的。Java语言的语法与C语言和C++语言很接近, Java丢弃了C++

中很少使用、难理解的的特性,如操作符重载、多继承、自动的强制类型转换。Java语言不使用指针,并提供了自动的废料收集。Java语言是一个面向对象的。Java语言提供类、接口和继承等原语,为了简单起见,只支持类之间的单继承,但支持接口之间的多继承,并支持类与接口之间的实现机制(关键字为implements)。Java语言全面支持动态绑定,而C++ 语言只对虚函数使用动态绑定。总之,Java语言是一个纯的面向对象程序设计语言。Java语言是分布式的。Java语言支持Internet应用的开发, Java的RMI(远程方法激活)机制也是开发分布式应用的重要手段。Java语言是健壮的。Java的强类型机制、异常处理、废料的自动收集等是Java程序健壮性的重要保证。Java语言是安全的。Java通常被用在网络环境中,为此,Java提供了一个安全机制以防恶意代码的攻击。

Java语言是可移植的。这种可移植性来源于体系结构中立性。Java系统本身也具有很强的可移植性。Java语言是多线程的。在Java语言中,线程是一种特殊的对象,它必须由Thread类或其子(孙)类来创建。 Java语言支持多个线程的同时执行,并提供多线程之间的同步机制(关键字为synchronized)。

Java语言的优良特性使得Java应用具有无比的健壮性和可靠性,这也减少了应用系统的维护费用。Java对对象技术的全面支持和Java平台内嵌的API能缩短应用系统的开发时间并降低成本。Java的编译一次,到处可运行的特性使得它能够提供一个随处可用的开放结构和在多平台之间传递信息的低成本方式。

Hibernate

Hibernate是JDBC的轻量级的对象封装。它是一个的对象持久层框架,和App Server,和EJB没有什么必然的联系。Hibernate可以用在任何JDBC可以使用的场合,例如Java应用程序的数据库访问代码,DAO接口 的实现类,甚至可以是BMP里面的访

问数据库的代码。从这个意义上来说,Hibernate和EB不是一个范畴的东西,也不存在非此即彼的关系。

Hibernate是一个和JDBC密切关联的框架,所以Hibernate的兼容性和JDBC驱动,和数据库都有一定的关系,但是和使用它的Java程序,和App Server没有任何关系,也不存在兼容性问题。

Hibernate 中提供了两级Cache,第一级别的缓存是Session级别的缓存,它是属于事务范围的缓存。这一级别的缓存由hibernate管理的,一般情况下无需进行干预;第二级别的缓存是SessionFactory级别的缓存,它是属于进程范围或群集范围的缓存。这一级别的缓存可以进行配置和更改,并且可以动态加载和卸载。 Hibernate还为查询结果提供了一个查询缓存,它依赖于第二级缓存。

当应用程序调用Session的save()、update()、saveOrUpdate()、get()或load(),以及调用查询接口的 list()、iterate()或filter()方法时,如果在Session缓存中还不存在相应的对象,Hibernate就会把该对象加入到第一级缓存中。当清理缓存时,Hibernate会根据缓存中对象的状态变化来同步更新数据库。 Session为应用程序提供了两个管理缓存的方法: evict(Object obj):从缓存中清除参数指定的持久化对象。 clear():清空缓存中所有持久化对象。

Hibernate的二级缓存策略的一般过程如下:

1) 条件查询的时候,总是发出一条select * from table_name where …. (选择所有字段)这样的SQL语句查询数据库,一次获得所有的数据对象。

2) 把获得的所有数据对象根据ID放入到第二级缓存中。

3) 当Hibernate根据ID访问数据对 象的时候,首先从Session一级缓存中查;查不到,如果配置了二级缓存,那么从二级缓存中查;查不到,再查询数据库,把结果按照ID放入到缓存。

4) 删除、更新、增加数据的时候,同时更新缓存。

Hibernate的二级缓存策略,是针对于ID查询的缓存策略,对于条件查询则毫无作用。为此,Hibernate提供了针对条件查询的Query Cache。

Hibernate对象关系映射提供延迟的与非延迟的对象初始化。非延迟加载在读取一个对象的时候会将与这个对象所有相关的其他对象一起读取出来。这有时会导致成百的(如果不是成千的话)select语句在读取对象的时候执行。这个问题有时出现在使用双向关系的时候,经常会导致整个数据库都在初始化的阶段被读出来了。当然,你可以不厌其烦地检查每一个对象与其他对象的关系,并把那些最昂贵的删除,但是到最后,我们可能会因此失去了本想在ORM工具中获得的便利。

一级缓存和二级缓存的比较:第一级缓存 第二级缓存 存放数据的形式 相互关联的持久化对象 对象的散装数据 缓存的范围 事务范围,每个事务都有单独的第一级缓存进程范围或集群范围,缓存被同一个进程或集群范围内的所有事务共享 并发访问策略由于每个事务都拥有单独的第一级缓存,不会出现并发问题,无需提供并发访问策略由于多个事务会同时访问第二级缓存中相同数据,因此必须提供适当的并发访问策略,来保证特定的事务隔离级别 数据过期策略没有提供数据过期策略。处于一级缓存中的对象永远不会过期,除非应用程序显式清空缓存或者清除特定的对象必须提供数据过期策略,如基于内存的缓存

中的对象的最大数目,允许对象处于缓存中的最长时间,以及允许对象处于缓存中的最长空闲时间 物理存储介质内存内存和硬盘。对象的散装数据首先存放在基于内存的缓存中,当内存中对象的数目达到数据过期策略中指定上限时,就会把其余的对象写入基于硬盘的缓存中。缓存的软件实现 在Hibernate的Session的实现中包含了缓存的实现由第三方提供,Hibernate仅提供了缓存适配器(CacheProvider)。用于把特定的缓存插件集成到Hibernate中。启用缓存的方式只要应用程序通过Session接口来执行保存、更新、删除、加载和查询数据库数据的操作,Hibernate就会启用第一级缓存,把数据库中的数据以对象的形式拷贝到缓存中,对于批量更新和批量删除操作,如果不希望启用第一级缓存,可以绕过Hibernate API,直接通过JDBC API来执行指操作。用户可以在单个类或类的单个集合的粒度上配置第二级缓存。如果类的实例被经常读但很少被修改,就可以考虑使用第二级缓存。只有为某个类或集合配置了第二级缓存,Hibernate在运行时才会把它的实例加入到第二级缓存中。 用户管理缓存的方式第一级缓存的物理介质为内存,由于内存容量有限,必须通过恰当的检索策略和检索方式来加载对象的数目。Session的evit()方法可以显式清空缓存中特定对象,但这种方法不值得推荐。 第二级缓存的物理介质可以是内存和硬盘,因此第二级缓存可以存放大量的数据,数据过期策略的maxElementsInMemory属性值可以控制内存中的对象数目。管理第二级缓存主要包括两个方面:选择需要使用第二级缓存的持久类,设置合适的并发访问策略:选择缓存适配器,设置合适的数据过期策略。

一个明显的解决方法是使用Hibernate提供的延迟加载机制。这种初始化策略只在一个对象调用它的一对多或多对多关系时才将关系对象读取出来。这个过程对开发者来说是透明的,而且只进行了很少的数据库操作请求,因此会得到比较明显的性能提升。这项技术的一个缺陷是延迟加载技术要求一个Hibernate会话要在对象使用的时候一直开着。这会成为通过使用DAO模式将持久层抽象出来时的一个主要问题。为了将持久化机制完全地抽象出来,所有的数据库逻辑,包括打开或关闭会话,都不能在应用层出现。最常见的

是,一些实现了简单接口的DAO实现类将数据库逻辑完全封装起来了。一种快速但是笨拙的解决方法是放弃DAO模式,将数据库连接逻辑加到应用层中来。这可能对一些小的应用程序有效,但是在大的系统中,这是一个严重的设计缺陷,妨碍了系统的可扩展性。

Struts2

Struts2其实并不是一个陌生的Web框架,Struts2是以Webwork的设计思想为核心,吸收了Struts1的优点,因此,可以认为Struts2是Struts1和Webwork结合的产物。

MVC简介:Struts2是一个兼容Struts1和WebWork的MVC框架,既然,提到了MVC框架,就不得不对MVC框架做一个简单介绍,仅限于简单介绍,如果,想了解更多的MVC的知识可以查看相关的文档,或者找一本Struts1的书籍,相信上面关于MVC的篇幅不会很少。言归正传,其实,Java目前出现的这些框架而言,其最终目的都是为了接触耦合,不论是Spring、Hibernate或MVC框架,目的都是为了接触耦合增加复用。MVC接触的是View和Model间的耦合。MVC包含三个基础部分:Model、View和Controller,这三个部分以最小的耦合协同工作,以增加程序的可扩展性和可维护性。各个部分的实现技术可以总结如下:

1)Model:JavaBean、EJB的EntityBean

2)View:JSP、Struts的TagLib

3)Controller:Struts的ActionServlet、Action

概括起来MVC的优点主要有一下方面:

1)多个视图可以对应一个模型。按MVC设计模式,一个模型对应多个视图,可以减少代码的复制及代码的维护量,一旦模型发生改变,也易于维护

2)模型返回的数据与显示逻辑分离。模型数据可以应用任何的显示技术,例如,使用JSP页面、Velocity模板或者直接产生Excel文档等

3)应用被分隔为三层,降低了各层之间的耦合,提供了应用的可扩展性

4)控制层的概念也很有效,由于它把不同的模型和不同的视图组合在一起,完成不同的请求。因此,控制层可以说是包含了用户请求权限的概念

5)MVC更符合软件工程化管理的精神。不同的层各司其职,每一层的组件具有相同的特征,有利于通过工程化和工具化产生管理程序代码。

Struts2简介: Struts2看似是从Struts1发展而来,但实际上Struts2与Struts1在框架的设计思想上面还是有很大的区别,Struts2是以WebWork的设计思想为核心,为什么Struts2不沿用Struts1的设计思想,毕竟Struts1在目前的企业应用中还是有非常大的市场在的, Struts1的一些缺点:

1)支持的表现层技术单一

2)与Servlet API严重耦合,这点可以从Action的Execute的方法声明里面就可以看的出来

3)代码依赖Struts1 API,有侵入性,这点可以从写Action类和FormBean的时候看的出来,Action必须实现Struts的Action类

而Struts2之所以以WebWork的设计思想为其核心,一点就是最近WebWork的上升势头,再就是WebWork没有Struts1上面的那些缺点,更符合MVC的设计思想,也更利于代码的复用。基于以上介绍可以看的出,Struts2体系结构与Struts1的体系结构有很大的差别,Struts1是使用ActionServlet做为其中心处理器,Struts2则使用一个(FilterDispatcher)做为其中心处理器,这样做的一个好处就是将Action类和Servlet API进行了分离。

Struts2的简单处理流程如下:

1)浏览器发送请求

2)中心处理器根据struts.xml文件查找对应的处理请求的Action类

3)WebWork的链自动对请求应用通用功能,例如:WorkFlow、Validation等功能

4)如果Struts.xml文件中配置Method参数,则调用Method参数对应的Action类中的Method方法,否则调用通用的Execute方法来处理用户请求。

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- zicool.com 版权所有 湘ICP备2023022495号-2

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务