) Java nouns

Source: Internet
Author: User
Tags object serialization

? >vo:? value-object >dto:data Transform Object >dtd:document Type Definition????? A document type definition is a set of syntax rules about a marker. It is part of the standard generic markup language and Extensible Markup Language version 1.0 specification, which is a document validation mechanism.

>junit: A unit test framework for a Java language >jboss: An open source application server based on the Java EE

>pojo
? ? ? POJO (Plain old Java object) Simple Java objects, actually is the ordinary JavaBeans, is to avoid and EJB confusion created by the abbreviation.
The Pojo name is used to avoid confusion with EJBS, and the abbreviation is more straightforward. There are classes of properties and their getter setter methods, there is no business logic and can sometimes be used as VO (value-object) or DTO (Data Transform object). Of course, if you have a simple arithmetic attribute is also possible, However, there are no business methods, nor can we carry methods such as connection.

Example 1
? ? ? Pojo has some private parameters as properties of the object. The Get and set methods are then defined for each parameter as an interface for access. For example:
public class User {
????? Private long ID;
????? private String name;
????? public void SetId (long id) {
?????????? This. id = ID;
?????}
????? public void SetName (String name) {
?????????? This. Name=name;
?????}
????? Public long getId () {
?????????? return ID;
?????}
????? Public String GetName () {
?????????? return name;
?????}
}
? ? ? Pojo objects are sometimes referred to as data objects, and are used in large numbers to represent objects in reality. If the hibernate framework is used in the project, there is an associated XML file that corresponds to the table in the database, and the properties of the object correspond to the fields in the table.

the wrong understanding:
????? Pojo is a "pure" JavaBean in which there is nothing else in it except the methods and properties of the JavaBean specification, namely the private property and the get and set methods of public for this property method. We will find that this kind of javabean is very "simple", it can only load data, as the carrier of data storage, and not have the ability of business logic processing.
the real meaning:
????? POJO = "Plain Old Java object", a term invented by Martinfowler, is used to denote common Java objects, not JavaBean, Entitybean, or Sessionbean. Pojo does not play any special role, nor does it implement any special Java framework interfaces such as, EJB,JDBC, etc.
????? That is, Pojo is a simple generic Java object that does not contain business logic or persistent logic, but not JavaBean, Entitybean, etc., and does not have any special roles and classes or interfaces that do not inherit or implement any other Java framework.
>javabean
JavaBean is a Java class, but for the sake of editing tool recognition, certain conditions need to be met (using Hibernate to automatically generate mapper and entity will know), here the specific three conditions are:
1) Implementation of the Java.io.Serializable interface
2) Provide parameterless constructors
3) Use Getter and setter methods to access its properties
Ejb
??? in enterprise development, the need for scalable performance and transaction, security mechanism, so as to ensure the smooth development of enterprise systems, rather than the development of a scale to replace a set of software systems. Then there was an increase in protocol requirements, and an enterprise Bean appeared.
EJB has made some demands on the basis of JavaBean, which is of course more complicated.
(from the requirements, Ejb>javabean>pojo)

>EJB:? Enterprise Bean
Introduction to EJBs
1. We cannot help but ask what is a "service cluster"? What is "enterprise-level development"?
??? Since the EJB is for "service clusters" and "enterprise-level development", then it is necessary to say what is called "Service Cluster" and "Enterprise-level development"!
This question is actually very important, because the Java EE does not explain the white, there is no specific indicators or examples tell the vast numbers of programmers when to use EJB when not. So we all have some associations, that the EJB "distributed operation" refers to "load balancing" to improve the efficiency of the system. However, it is estimated that many people are mistaken that this "service cluster" and "distributed operation" do not solve the problem of running load at all, especially the application system for database. Why? Let's take the EJB back to the prototype and analyze it slowly.

2. Break the EJB and crush it.
??? We have a good analysis of the EJB concept to see what clues can be found.

Analysis of 3.1 EJB concept
??? Let's take a look at the official explanation of EJB:
The core part of business software is its business logic. Business logic abstracts the process of the entire business process and uses the computer language to implement them. ......
? ? ? The approach of Java EE to this problem is to extract the business logic from the client software and encapsulate it in a component. This component runs on a separate server, where the client software invokes the service provided by the component through the network to implement the business logic, and the client software functions simply to send the call request and display the processing results. In the Java EE, this component, which runs on a separate server and encapsulates the business logic, is the EJB (Enterprise JavaBean) component.
Here we mainly focus on these points, we have to analyze:
??? Anatomy 1: The so-called "business logic" we note that the main reference in the EJB concept is the encapsulation of "business logic", and what exactly is this business logic? So poised, in fact, this so-called "business logic" we can fully understand as the implementation of a specific task "class."
??? Anatomy 2: The so-called: "Extract the business logic from the client software, encapsulated in the component ... Running on a server "since we know that the concept of" business logic "is the" class "that performs a particular task, what is called" extracting from the client software "? In fact, this is the original put on the client's "class", take it out to the client, put in a component, and put this component on a server to run.
3.2 Turning the concept of EJB into plain English into plain English is, "the class of the software you write that needs to be executed is not put on the client software, but instead is placed on a server with a packet."
3.3 Found a problem.
??? Whether it's "stereotyped writing" or "plain English," The EJB concept mentions a word-"client software". "Client Software"? Does the concept of EJB say C/s software?
??? Yes, that's right! EJB is to put those "classes" on a server, in the form of C/S software client to the "class" on the server call。 It's going to crash!
? ? ? What is the relationship between EJB and JSP? EJB and JSP are related, but the relationship is not very big, at most on the server side of the JSP call the remote service EJB class, that's all.

4.1 What is the bottom of EJB?
??? We uncover the true meaning of the EJB "stereotyped" concept, then analyze the EJB's underlying implementation techniques to analyze the EJB's working methods through the underlying implementation techniques.
Implementation technology of 4.2 EJB
? ? ? An EJB is a component that runs on a stand-alone server, and the client invokes the EJB object over the network. In Java, the technology that enables remote object invocation is RMI, and The EJB Technology Foundation is RMI. With RMI technology, Java EE creates the EJB component as a remote object, and the client can invoke the EJB object over the networkThe
4.3 See what RMI is.
Before you say RMI, you need to understand two nouns: the serialization of an object
??? distributed computing and RPC
??? Noun 1: Serialization of objects
??? The serialization concept of an object: the serialization of an object is the process of converting an object's state into a byte stream and recovering an object from a byte stream. After you convert the object state to a byte stream, you can either save it to a file with the various byte stream classes in the Java.io package, or send the object data to another host over a network connection.
The above statement is a bit "stereotyped", we may as well explain in the vernacular: Object serialization is the object of a class that instantiates your program, for example, you customize a class MyClass, or any object of a class, convert it to a byte array, that can be placed in a byte array, Now that you have put an object in a byte array, you can certainly dispose of it, and the most used is to send him to a remote computer on the network. shown in 2 11.
?? ?? Noun 2: Distributed computing and RPC
? ? ? RPC is not a purely Java concept because the concept of RPC was already in existence before Java was born. RPC is "Remote Procedure Call"The abbreviation for" Remote Procedure call ". Most programming languages Prior to Java, such as Fortran, C, COBOL, and so on, are procedural languages, not object-oriented. So, these programming languages naturally use procedures to represent work, such as functions or subroutines, to be executed on another machine on the network. To be blunt, the local computer calls a function on the remote computer.
Shown in 2 12.
?? ?? Noun 3: The combination of the two is RMI
? ? ? RMI English full name is "Remote Method invocation", its Chinese name is "remote method call", it is the use of Java object serialization mechanism to implement distributed computing, the realization of the remote class object instantiation and the method of invocation. To speak more clearly, is to using object serialization to implement remote calls, that is, the combination of the above two concepts, the use of this method to invoke the remote class, there is no need to write the socket program, and do not need to serialize the object, the direct call on the line is very convenient. A remote method call is a mechanism by which objects between computers invoke each other's functions to initiate a process that uses the same program syntax rules as the syntax rules of a method call between objects on a local machine when an object on one computer calls a method on another computer.

4.4 Advantages
This mechanism brings great convenience to the design and programming of distributed computing systems. As long as the program is designed according to the RMI rules, you can avoid having to ask about the network details under RMI, such as TCP and sockets, and so on. The communication between any two computers is solely the responsibility of RMI. Invoking objects on a remote computer is as convenient as a local object. RMI can pass complete objects as parameters and return values, not just predefined data types. In other words, a complex type such as a Java hash table can be passed as a parameter.
4.5 Disadvantages
??? If it is a simpler method call, its execution might be much slower than local execution, even if it is slower than the application of the remote socket mechanism's simple data return, because the information it needs to pass across the network contains more than the return value information of the function. It also contains the byte content after the object is serialized.
4.6? EJB is based on RMIOf
???. with RMI technology, Java EE creates EJB components as remote objects, while EJBS use RMI technology, but only need to define remote interfaces without generating their implementation classes, which masks some of the details of RMI technology. But anyway, the basis of EJB is still RMI, so if you want to understand the principle of EJB, as long as the principle of RMI to clear the line. You can also figure out when to use EJBS when you don't need ejbs.

5. The so-called "service Cluster" in EJBS
As already known, RMI is to put a variety of tasks and functions of the classes on different servers, and then through the various servers established by the call rules to achieve distributed operations, it is clear The concept of EJB's so-called "service Cluster". is to put a few classes that were originally operating on a computer and run it on another computer to share the CPU and memory resources that are required to run the classes. At the same time, different software function modules can also be placed on different servers, when the need to modify some features of the server directly modify the class on the line, all client software has been modified after the modification.

6. Is this deployment impeccable?
This "service cluster" seems "invulnerable", in fact, it is not a picture of the complete, we come to complete the picture, and then to see what the problem is not.
6.1 Bottlenecks on the database side
After careful observation, it is found that this configuration has a bottleneck??? ?? Now if you want to implement individual server queries for the same database, no matter how many feature servers you deploy, requires a query operation on a database server。 In other words, no matter how "distributed" Your calculations are, you also need to get data from one server. Although it seems that the various functional modules are distributed across different servers to share the CPU resources of each host computer, the real bottleneck is not here, but the database server. The database server is very busy responding to queries and operational requests from individual servers.
So, through this diagram, we understand that EJB simply does not fully solve the problem of load, because the bottleneck is not in the location of the function module, but in the database server here.
6.2 What if we separate the database and share the data
Some readers will certainly think of the following application structure, which is Do you want to deploy a database behind each of the feature servers so that you don't solve the problem in the previous section? Yes, it solves the problem of database query load, but there are new problems, that is, the problem of "data sharing" is not easy to solve.The
6.3 The network is under great pressure to make your application slow as the old bull
Let's go ahead and look at this. 2 15 shows that there are two networks in this architecture, one is "a network" is a "B network", the two networks are different. "B Network" is often a local area network, the general bandwidth is 10m/100m, faster, so fortunately, however, "A network" is often the Internet or the use of telecommunications network interconnection VPN network or called WAN. "A network" is characterized by a narrow bandwidth, such as ADSL network only has 512k-2m bandwidth, because of the high cost of WAN interconnection, so there is generally no higher bandwidth. In this network is running the function module and the client software exchange between the data, and this part of the data is the advantage of very bandwidth-intensive. As a result, the application architecture can see how slow it is to run. To say a word is not exaggerated, a little bit like the old bull pull the same slow car. A system such as the old cow:
At present, in China, the Internet as a carrier network management system of a large company, its early management software is the use of this architecture to do the C/s structure of the application system.
Once, as an evaluator, I evaluated the application system and deployed it to a non-carrier large network, the situation that we described above, the speed is unbearable, open a traffic map, sometimes it takes 15 minutes to render complete. However, the system did not find this problem in the development phase, why? Because they did not take into account the complexity of the actual user connection to the network, thus causing a large loss to the company, the development architecture was eventually abandoned.

7. EJB Ingenious, the Java EE is not required to use EJB
It seems as if the system relationship between EJB and the B/s structure of the Web application is not big, but it is not. If we understand the "client program" as a server, it can also be applied, and if the server makes EJB calls to each other, there is no problem of WAN bandwidth limitation.
However, do not use EJBS as much as possible:
1, simple Web application development, do not need to use EJB.
2. Applications that need to be used in conjunction with other service programs, but invoke or return custom network protocols that can be resolved by applications that do not require the use of EJBS.
3, more people concurrent access to the C/s structure of the application, try not to use EJB.
Summarize:
A. The principle of EJB implementation: is to put the original client implementation of the code on the server side, and rely on RMI to communicate.
B.rmi implementation principle: It is through the Java object Serializable mechanism to achieve the distribution of computing.
C. server cluster: It is through RMI communication, connect the server of different function module, in order to realize a complete function.

) Java nouns

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.